Submission #22291

#TimeUsernameProblemLanguageResultExecution timeMemory
22291크리콘 B번 문제는 그리디로 풀려요 (#40)Fully Generate (KRIII5_FG)C++98
2 / 7
500 ms130060 KiB
#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;

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

Compilation message (stderr)

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:26:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &N); lld dap=1;
                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...