Submission #22653

#TimeUsernameProblemLanguageResultExecution timeMemory
22653AJAE (#40)Fully Generate (KRIII5_FG)C++14
7 / 7
239 ms246020 KiB
#include <cstdio>
#include <algorithm>

using namespace std;
using ll = long long;
const ll MMOD = 1000000007;
const ll MAXN = 31347599;

inline ll popo(ll a, ll p) {
    ll r =1;
    while(p) {
        if(p&1) r= (r*a)%MMOD;
        a = (a*a) % MMOD;
        p >>= 1LL;
    }
    return r;
}

ll arr[MAXN] = {0,1,2,2,};
int sss[6] = {0,1,2,4,12,36};
int main()
{
    ll n;
    ll cnt = 5;
    ll ans = 36;
    scanf("%lld", &n);
    if(n<=5) {
        printf("%d\n", sss[n]);
        return 0;
    }
    ll gsize = 4;
    bool sw = true;
    for(int i=3;sw;++i){
        ll ttmp = 1;
        ll st = gsize;
        for(ll j=0;j<arr[i];++j) {
            cnt += i;
            if (cnt >= n) {
                ans = (ans * popo(ttmp, i))%MMOD;
                ans = (ans * popo(gsize, i - (cnt-n)))%MMOD;
                printf("%lld\n", ans);
                return 0;
            }
            arr[gsize] = i;
            ttmp = (ttmp * gsize) % MMOD;
            gsize++;
        }
        ans = (ans * popo(ttmp, i))%MMOD;
    }

    return 0;
}

Compilation message (stderr)

FG.cpp: In function 'int main()':
FG.cpp:35:12: warning: unused variable 'st' [-Wunused-variable]
         ll st = gsize;
            ^
FG.cpp:26:22: 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...