제출 #22497

#제출 시각아이디문제언어결과실행 시간메모리
22497버거킹 송죽SK점 우수고객 (#40)Fully Generate (KRIII5_FG)C++14
7 / 7
296 ms252020 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...