# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
22729 | 도치피치피보족 (#40) | Fully Generate (KRIII5_FG) | C++11 | 0 ms | 16740 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |