답안 #22317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22317 2017-04-30T03:50:22 Z 크리콘 B번 문제는 그리디로 풀려요(#918, imsifile) Fully Generate (KRIII5_FG) C++
7 / 7
263 ms 130468 KB
#include<stdio.h>

typedef long long lld;
const lld mx = 1000000000000;
const lld mod = 1000000007;

lld exp(lld a, lld b){
	lld g=1, a0=a, b0=b;
	while(b){
		if(b&1)g=g*a%mod;
		b>>=1, a=a*a%mod;
	}
	return g;
}

int poi[33010101], cnt;
lld sum, N, gop[52000];

int main(){
	poi[1]=1, gop[1]=1;
	poi[2]=poi[3]=2, gop[2]=6; cnt=4; sum=5;
	for(int i=3;; i++){
		gop[i]=1;
		for(int j=poi[i]; j--;){
			poi[cnt]=i;
			gop[i] = gop[i]*cnt % mod;
			cnt++, sum+=i;
		}
		if(sum > mx) break;
	}
	scanf("%lld", &N); lld dap=1;
	lld N2=N, lim=0, comp=0;
	for(int i=1; i<cnt; i++){
		if(N2 >= poi[i])lim++, N2 -= poi[i];
		else { dap = exp(i,N2)%mod; break; }
	}
	for(int i=1; i<cnt; i++){
		if(comp + poi[i] <= lim) dap = dap*exp(gop[i],i)%mod, comp += poi[i];
		else break;
	}
	for(lld i=comp+1; i<=lim; i++) dap = dap*exp(i,poi[i])%mod;
	printf("%lld", dap);
	return 0;
}

Compilation message

FG.cpp: In function 'lld exp(lld, lld)':
FG.cpp:8:11: warning: unused variable 'a0' [-Wunused-variable]
  lld g=1, a0=a, b0=b;
           ^
FG.cpp:8:17: warning: unused variable 'b0' [-Wunused-variable]
  lld g=1, a0=a, b0=b;
                 ^
FG.cpp: In function 'int main()':
FG.cpp:31:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &N); lld dap=1;
                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 130468 KB Output is correct
2 Correct 176 ms 130468 KB Output is correct
3 Correct 206 ms 130468 KB Output is correct
4 Correct 219 ms 130468 KB Output is correct
5 Correct 186 ms 130468 KB Output is correct
6 Correct 189 ms 130468 KB Output is correct
7 Correct 206 ms 130468 KB Output is correct
8 Correct 203 ms 130468 KB Output is correct
9 Correct 203 ms 130468 KB Output is correct
10 Correct 213 ms 130468 KB Output is correct
11 Correct 196 ms 130468 KB Output is correct
12 Correct 186 ms 130468 KB Output is correct
13 Correct 206 ms 130468 KB Output is correct
14 Correct 203 ms 130468 KB Output is correct
15 Correct 206 ms 130468 KB Output is correct
16 Correct 196 ms 130468 KB Output is correct
17 Correct 196 ms 130468 KB Output is correct
18 Correct 179 ms 130468 KB Output is correct
19 Correct 213 ms 130468 KB Output is correct
20 Correct 199 ms 130468 KB Output is correct
21 Correct 216 ms 130468 KB Output is correct
22 Correct 179 ms 130468 KB Output is correct
23 Correct 189 ms 130468 KB Output is correct
24 Correct 183 ms 130468 KB Output is correct
25 Correct 219 ms 130468 KB Output is correct
26 Correct 209 ms 130468 KB Output is correct
27 Correct 216 ms 130468 KB Output is correct
28 Correct 189 ms 130468 KB Output is correct
29 Correct 223 ms 130468 KB Output is correct
30 Correct 206 ms 130468 KB Output is correct
31 Correct 186 ms 130468 KB Output is correct
32 Correct 213 ms 130468 KB Output is correct
33 Correct 193 ms 130468 KB Output is correct
34 Correct 189 ms 130468 KB Output is correct
35 Correct 193 ms 130468 KB Output is correct
36 Correct 209 ms 130468 KB Output is correct
37 Correct 186 ms 130468 KB Output is correct
38 Correct 206 ms 130468 KB Output is correct
39 Correct 189 ms 130468 KB Output is correct
40 Correct 216 ms 130468 KB Output is correct
41 Correct 186 ms 130468 KB Output is correct
42 Correct 216 ms 130468 KB Output is correct
43 Correct 193 ms 130468 KB Output is correct
44 Correct 186 ms 130468 KB Output is correct
45 Correct 213 ms 130468 KB Output is correct
46 Correct 189 ms 130468 KB Output is correct
47 Correct 186 ms 130468 KB Output is correct
48 Correct 213 ms 130468 KB Output is correct
49 Correct 213 ms 130468 KB Output is correct
50 Correct 213 ms 130468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 130468 KB Output is correct
2 Correct 176 ms 130468 KB Output is correct
3 Correct 206 ms 130468 KB Output is correct
4 Correct 219 ms 130468 KB Output is correct
5 Correct 186 ms 130468 KB Output is correct
6 Correct 189 ms 130468 KB Output is correct
7 Correct 206 ms 130468 KB Output is correct
8 Correct 203 ms 130468 KB Output is correct
9 Correct 203 ms 130468 KB Output is correct
10 Correct 213 ms 130468 KB Output is correct
11 Correct 196 ms 130468 KB Output is correct
12 Correct 186 ms 130468 KB Output is correct
13 Correct 206 ms 130468 KB Output is correct
14 Correct 203 ms 130468 KB Output is correct
15 Correct 206 ms 130468 KB Output is correct
16 Correct 196 ms 130468 KB Output is correct
17 Correct 196 ms 130468 KB Output is correct
18 Correct 179 ms 130468 KB Output is correct
19 Correct 213 ms 130468 KB Output is correct
20 Correct 199 ms 130468 KB Output is correct
21 Correct 216 ms 130468 KB Output is correct
22 Correct 179 ms 130468 KB Output is correct
23 Correct 189 ms 130468 KB Output is correct
24 Correct 183 ms 130468 KB Output is correct
25 Correct 219 ms 130468 KB Output is correct
26 Correct 209 ms 130468 KB Output is correct
27 Correct 216 ms 130468 KB Output is correct
28 Correct 189 ms 130468 KB Output is correct
29 Correct 223 ms 130468 KB Output is correct
30 Correct 206 ms 130468 KB Output is correct
31 Correct 186 ms 130468 KB Output is correct
32 Correct 213 ms 130468 KB Output is correct
33 Correct 193 ms 130468 KB Output is correct
34 Correct 189 ms 130468 KB Output is correct
35 Correct 193 ms 130468 KB Output is correct
36 Correct 209 ms 130468 KB Output is correct
37 Correct 186 ms 130468 KB Output is correct
38 Correct 206 ms 130468 KB Output is correct
39 Correct 189 ms 130468 KB Output is correct
40 Correct 216 ms 130468 KB Output is correct
41 Correct 186 ms 130468 KB Output is correct
42 Correct 216 ms 130468 KB Output is correct
43 Correct 193 ms 130468 KB Output is correct
44 Correct 186 ms 130468 KB Output is correct
45 Correct 213 ms 130468 KB Output is correct
46 Correct 189 ms 130468 KB Output is correct
47 Correct 186 ms 130468 KB Output is correct
48 Correct 213 ms 130468 KB Output is correct
49 Correct 213 ms 130468 KB Output is correct
50 Correct 213 ms 130468 KB Output is correct
51 Correct 246 ms 130468 KB Output is correct
52 Correct 226 ms 130468 KB Output is correct
53 Correct 243 ms 130468 KB Output is correct
54 Correct 249 ms 130468 KB Output is correct
55 Correct 226 ms 130468 KB Output is correct
56 Correct 226 ms 130468 KB Output is correct
57 Correct 219 ms 130468 KB Output is correct
58 Correct 226 ms 130468 KB Output is correct
59 Correct 263 ms 130468 KB Output is correct
60 Correct 229 ms 130468 KB Output is correct
61 Correct 239 ms 130468 KB Output is correct
62 Correct 216 ms 130468 KB Output is correct
63 Correct 219 ms 130468 KB Output is correct
64 Correct 249 ms 130468 KB Output is correct
65 Correct 213 ms 130468 KB Output is correct
66 Correct 226 ms 130468 KB Output is correct
67 Correct 233 ms 130468 KB Output is correct
68 Correct 206 ms 130468 KB Output is correct
69 Correct 226 ms 130468 KB Output is correct
70 Correct 226 ms 130468 KB Output is correct
71 Correct 216 ms 130468 KB Output is correct
72 Correct 223 ms 130468 KB Output is correct
73 Correct 226 ms 130468 KB Output is correct
74 Correct 226 ms 130468 KB Output is correct
75 Correct 216 ms 130468 KB Output is correct
76 Correct 216 ms 130468 KB Output is correct
77 Correct 229 ms 130468 KB Output is correct
78 Correct 223 ms 130468 KB Output is correct
79 Correct 223 ms 130468 KB Output is correct
80 Correct 209 ms 130468 KB Output is correct
81 Correct 216 ms 130468 KB Output is correct
82 Correct 239 ms 130468 KB Output is correct
83 Correct 243 ms 130468 KB Output is correct
84 Correct 213 ms 130468 KB Output is correct
85 Correct 233 ms 130468 KB Output is correct
86 Correct 213 ms 130468 KB Output is correct
87 Correct 216 ms 130468 KB Output is correct
88 Correct 226 ms 130468 KB Output is correct
89 Correct 223 ms 130468 KB Output is correct
90 Correct 229 ms 130468 KB Output is correct
91 Correct 199 ms 130468 KB Output is correct
92 Correct 213 ms 130468 KB Output is correct
93 Correct 229 ms 130468 KB Output is correct
94 Correct 226 ms 130468 KB Output is correct
95 Correct 219 ms 130468 KB Output is correct
96 Correct 209 ms 130468 KB Output is correct
97 Correct 206 ms 130468 KB Output is correct
98 Correct 229 ms 130468 KB Output is correct
99 Correct 223 ms 130468 KB Output is correct
100 Correct 199 ms 130468 KB Output is correct
101 Correct 219 ms 130468 KB Output is correct
102 Correct 209 ms 130468 KB Output is correct
103 Correct 186 ms 130468 KB Output is correct
104 Correct 223 ms 130468 KB Output is correct
105 Correct 176 ms 130468 KB Output is correct
106 Correct 209 ms 130468 KB Output is correct
107 Correct 189 ms 130468 KB Output is correct
108 Correct 223 ms 130468 KB Output is correct
109 Correct 183 ms 130468 KB Output is correct
110 Correct 199 ms 130468 KB Output is correct
111 Correct 216 ms 130468 KB Output is correct
112 Correct 206 ms 130468 KB Output is correct
113 Correct 199 ms 130468 KB Output is correct
114 Correct 183 ms 130468 KB Output is correct
115 Correct 223 ms 130468 KB Output is correct
116 Correct 196 ms 130468 KB Output is correct
117 Correct 226 ms 130468 KB Output is correct
118 Correct 199 ms 130468 KB Output is correct
119 Correct 203 ms 130468 KB Output is correct
120 Correct 213 ms 130468 KB Output is correct