22702023-01-08 22:45:47kohumarkToronyépítés (2,2,3,3)cpp11Time limit exceeded 2/40300ms3584 KiB
#include <iostream>
using namespace std;

int ret(int sol, int a, int b, int c, int d){
	long long unsigned int ret=1; int q=a+b+c+d; int x=2;
	while(a>0||b>0||c>0||d>0||q+1>x){
		while(a>0){if(ret%a==0){ret=ret/a;a--;} else break;}
		while(b>0){if(ret%b==0){ret=ret/b;b--;} else break;}
		while(c>0){if(ret%c==0){ret=ret/c;c--;} else break;}
		while(d>0){if(ret%d==0){ret=ret/d;d--;} else break;}
		if(q>0) {ret=ret*x; x++;}
	}
	sol+=ret%20210108;
	return sol%20210108;
}

int main(){
	cin.tie(NULL); ios::sync_with_stdio(false);
	int n; cin >> n;
	int sol=0;
	int a=n/2+n%2;
	while(a<n+1){
		while((a%2&&a%3)&&a<n+1) a++;
		if(a%2==0){
			if((n-a)%3==0){
				for(int i=0; i<a/2+1; i++) for(int j=0; j<(n-a)/3+1; j++) sol=ret(sol,i,a/2-i,j,(n-a)/3-j);
			}
		}
		if(a%3==0){
			if((n-a)%2==0){
				for(int i=0; i<a/3+1; i++) for(int j=0; j<(n-a)/2+1; j++) sol=ret(sol,i,a/3-i,j,(n-a)/2-j);
			}
		}
		a++;
	}
	cout << sol;
}
SubtaskSumTestVerdictTimeMemory
base2/40
1Accepted0/03ms1892 KiB
2Time limit exceeded0/0300ms1328 KiB
3Wrong answer0/22ms2336 KiB
4Wrong answer0/22ms2536 KiB
5Wrong answer0/33ms2716 KiB
6Wrong answer0/32ms2924 KiB
7Time limit exceeded0/3270ms3100 KiB
8Time limit exceeded0/3256ms2440 KiB
9Wrong answer0/32ms3340 KiB
10Wrong answer0/32ms3388 KiB
11Time limit exceeded0/3280ms2616 KiB
12Time limit exceeded0/3256ms3464 KiB
13Time limit exceeded0/4261ms3488 KiB
14Time limit exceeded0/4264ms3568 KiB
15Wrong answer0/22ms3584 KiB
16Accepted2/22ms3584 KiB