Submission #22676

#TimeUsernameProblemLanguageResultExecution timeMemory
22676dried chocochip on Daegu asphalt (#40)Fully Generate (KRIII5_FG)C++11
7 / 7
363 ms314520 KiB
#include<bits/stdc++.h> using namespace std; const int INF = 1000000007; long long arr[40000000]; long long mul(long long n, long long m) { long long ret = 1; while(m) { if(m%2) ret = (ret*n)%INF; n = (n*n)%INF; m /= 2; } return ret; } int main() { long long ret = 1; arr[1] = 1; arr[2] = 2; long long n; scanf("%lld", &n); if(n == 1) { printf("1\n"); return 0; } long long t=n; n--; long long cur = 2, idx = 2; for(int i = 2; i < 40000000; i++) { for(int j = 0; j < arr[i]; j++) { if(idx == 40000000) break; arr[idx++] = cur; } cur++; } int head=1, tail=1; long long res=1; while(1) { long long mult=head, cnt=arr[head]; if(cnt>=t) { res*=mul(head,t); res%=INF; break; } while(arr[tail+1]==arr[tail] && cnt+arr[tail+1]<=t) { tail++; mult*=tail; cnt+=arr[tail]; mult %= INF; } res*=mul(mult,arr[tail]); res%=INF; t-=cnt; head=tail+1; tail=head; } printf("%lld\n", res); return 0; }

Compilation message (stderr)

FG.cpp: In function 'int main()':
FG.cpp:23:12: warning: unused variable 'ret' [-Wunused-variable]
  long long ret = 1;
            ^
FG.cpp:28:19: 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...