Submission #22729

# Submission time Handle Problem Language Result Execution time Memory
22729 2017-04-30T07:02:35 Z 도치피치피보족(#942, lyzqm123) Fully Generate (KRIII5_FG) C++11
0 / 7
0 ms 16740 KB
#include <cstdio>
typedef unsigned long long int P;
const P mod = 1000000007;
P index[1000001][2];
P N;
P curr = 3, num = 3, ind = 4;
P p = 1;
P whatindexinnum(P curr){
	for (p = p;; p++)
		if (curr >= index[p][0] && curr <= index[p][1])
			return p;
}
P pow(P x, P y){
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	if (y & 1) return x % mod* (pow(x, y - 1) % mod);
	else return (pow(x % mod, y / 2) % mod * pow(x %mod, y / 2) % mod) % mod;
}
int main(){
	P ans = 4;
	index[1][0] = index[1][1] = 1;
	index[2][0] = 2, index[2][1] = 3;

	scanf("%lld", &N);
	if (N == 1){ printf("1\n"); return 0; }
	else if (N == 2){ printf("2\n"); return 0;}
	else if (N == 3){ printf("4\n"); return 0;}
	else if (N == 4){ printf("12\n"); return 0;}
	while (1){
		long long len;
		index[num][0] = ind;
		index[num][1] = ind + whatindexinnum(curr) - 1;
		len = index[num][1] - index[num][0] + 1;

		if (N >= index[num][0] && N <= index[num][1]){
			len = N - index[num][0] + 1;
			ans = ((ans %mod)* (pow(num, len) % mod)) % mod;
			break;
		}
		else if (index[num][1] < N){
			ans = ((ans%mod)* (pow(num, len) % mod)) % mod;
		}
		
		ind = index[num][1] + 1;
		num++;
		curr++;
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

FG.cpp: In function 'int main()':
FG.cpp:24:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &N);
                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16740 KB Output is correct
2 Correct 0 ms 16740 KB Output is correct
3 Correct 0 ms 16740 KB Output is correct
4 Correct 0 ms 16740 KB Output is correct
5 Correct 0 ms 16740 KB Output is correct
6 Correct 0 ms 16740 KB Output is correct
7 Correct 0 ms 16740 KB Output is correct
8 Correct 0 ms 16740 KB Output is correct
9 Correct 0 ms 16740 KB Output is correct
10 Correct 0 ms 16740 KB Output is correct
11 Incorrect 0 ms 16740 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16740 KB Output is correct
2 Correct 0 ms 16740 KB Output is correct
3 Correct 0 ms 16740 KB Output is correct
4 Correct 0 ms 16740 KB Output is correct
5 Correct 0 ms 16740 KB Output is correct
6 Correct 0 ms 16740 KB Output is correct
7 Correct 0 ms 16740 KB Output is correct
8 Correct 0 ms 16740 KB Output is correct
9 Correct 0 ms 16740 KB Output is correct
10 Correct 0 ms 16740 KB Output is correct
11 Incorrect 0 ms 16740 KB Output isn't correct
12 Halted 0 ms 0 KB -