답안 #22520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22520 2017-04-30T05:18:10 Z AJAE(#998, nona1314, adman, wowoto9772) Fully Generate (KRIII5_FG) C++14
0 / 7
0 ms 246020 KB
#include <cstdio>
#include <vector>

using namespace std;
using ll = long long;
ll MMOD = 1000000007;
ll popo(ll a, ll p) {
	ll r = 1;
	while (p) {
		if (p & 1) {
			ll v = r*a;
			if (v >= MMOD)v %= MMOD;
			r = v;
		}
		a = (a*a) % MMOD;
		ll v = a*a;
		if (v >= MMOD)v %= MMOD;
		a = v;
		p >>= 1LL;
	}
	return r;
}

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

	return 0;
}

Compilation message

FG.cpp: In function 'int main()':
FG.cpp:47:7: warning: unused variable 'st' [-Wunused-variable]
   int st = gsize;
       ^
FG.cpp:31:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 246020 KB Output is correct
2 Correct 0 ms 246020 KB Output is correct
3 Correct 0 ms 246020 KB Output is correct
4 Correct 0 ms 246020 KB Output is correct
5 Correct 0 ms 246020 KB Output is correct
6 Correct 0 ms 246020 KB Output is correct
7 Incorrect 0 ms 246020 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 246020 KB Output is correct
2 Correct 0 ms 246020 KB Output is correct
3 Correct 0 ms 246020 KB Output is correct
4 Correct 0 ms 246020 KB Output is correct
5 Correct 0 ms 246020 KB Output is correct
6 Correct 0 ms 246020 KB Output is correct
7 Incorrect 0 ms 246020 KB Output isn't correct
8 Halted 0 ms 0 KB -