이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 3.2e7, mod = 1e9+7;
ll n, a[N+5] = {0, 1, 2, 2}, cur = 4, ans = 1, x = 1;
ll sans[7] = {0, 1, 2, 4, 12, 36};
ll calc (ll A, ll B) {
if(!B) return 1;
ll ret = calc(A, B/2);
ret = (ret * ret) % mod;
if(B & 1) ret = (ret * A) % mod;
return ret;
}
int main()
{
scanf("%lld",&n);
if(n <= 5) {printf("%lld\n",sans[n]); return 0;}
n -= 5;
for(int i=3;;i++) {
for(int j=1;j<=a[i];j++) {
if(n <= i) {
ans = calc(cur, n);
n = 0;
break;
}
a[cur++] = i;
n -= i;
}
if(!n) break;
}
for(int i=cur-1;i>=1;i--) {
x = (x * i) % mod;
if(a[i] != a[i-1]) ans = (ans * x) % mod;
}
printf("%lld\n",ans);
}
컴파일 시 표준 에러 (stderr) 메시지
FG.cpp: In function 'int main()':
FG.cpp:18:18: 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... |