제출 #1163335

#제출 시각아이디문제언어결과실행 시간메모리
1163335kjy2014팩토리얼 세제곱들의 합 (YDX14_fact)C++20
1 / 1
0 ms328 KiB
#include<bits/stdc++.h>
#define M	40
#define B	1000000000000
int power(int a,int k) 
{
  return k==0?1:power(a,k-1)*a;
}
int main()
{
  static long long aa[M],ss[M];
  int n,k,h,i,x;
  scanf("%d%d",&n,&k);
  aa[0]=ss[0]=1;
  for(i=1;i<=n;i++)
  {
  	x=power(i,k);
  	for(h=0;h<M;h++)
  		aa[h]*=x;
  	for(h=0;h+1<M;h++)
  		aa[h+1]+=aa[h]/B,aa[h]%=B;
  	if(aa[M-1]>=B)
  	{
  		printf("bad\n");
  		return 0;
  	}
  	for(h=0;h<M;h++)
  		ss[h]+=aa[h];
  	for(h=0;h+1<M;h++)
  		ss[h+1]+=ss[h]/B,ss[h]%=B;
  	if(ss[M-1]>=B)
  	{
  		printf("bad\n");
  		return 0;
  	}
  }
  h=0;
  while(ss[h]==0)
  	h++;
  while(ss[h]%10==0)
  	ss[h]/=10;
  printf("%lld\n",ss[h]%10);
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

fact.cpp: In function 'int main()':
fact.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d%d",&n,&k);
      |   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...