제출 #22554

#제출 시각아이디문제언어결과실행 시간메모리
22554King_God_OnionPringles (#40)Fully Generate (KRIII5_FG)C++98
2 / 7
19 ms787176 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...