이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define je 1000000007
using namespace std;
long long gop(int x, int y){
long long poww = x;
long long ans = 1;
int left = y;
while(left){
if(left & 1){
ans = (ans * poww) % je;
}
poww = (poww * poww) % je;
left >>= 1;
}
return ans;
}
#define mx 1000000
int cnt[mx+1];
long long fact[mx*100+1];
int main(){
long long n;
scanf("%lld",&n);
long long ans = 1;
fact[0] = 1;
for(int i=1;i<=mx;i++){
fact[i] = (fact[i-1] * i) % je;
}
int ss = 0, ee = 0, now = 0;
cnt[1] = 1; cnt[2] = 2;
for(int i=1;;i++){
ss = ee+1;
ee = ee+cnt[i];
//printf("%d %d %d %lld\n",i,ss,ee, n);
if(ss<100000){
for(int j=ss;j<=ee;j++){
cnt[j] = i;
}
}
now++;
long long gae = (long long)cnt[i] * i;
//if(now>5000) printf("%lld\n",gae);
//printf("%d %d\n",i, ee);
if(n <= gae){
int ee = (ss-1) + (n / i);
long long cal = (fact[ee] * gop((int)fact[ss-1], je - 2)) % je;
ans = (ans * gop((int)cal,i)) % je;
ans = (ans * gop(ee+1, (int)(n % i))) % je;
break;
}else{
n -= gae;
long long cal = (fact[ee] * gop((int)fact[ss-1], je - 2)) % je;
ans = (ans * gop((int)cal, i)) % je;
}
}
printf("%lld",ans);
}
컴파일 시 표준 에러 (stderr) 메시지
FG.cpp: In function 'int main()':
FG.cpp:25:21: 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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |