제출 #21160

#제출 시각아이디문제언어결과실행 시간메모리
21160jayceking팩토리얼 세제곱들의 합 (YDX14_fact)C++14
1 / 1
0 ms1116 KiB
#include<cstdio>

int pow(int a, int b, int c) {
	if (b == 0) return c;
	pow(a, b - 1, a*c);
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int d = 0;
	int arr[5] = { 1,1,2,6,24 };
	if (n > 4) {
		for (int i = 0;i <= 4;++i) {
			d += pow(arr[i], k, 1);
		}
	}
	else {
		for (int i = 0;i <= n;++i) {
			d += pow(arr[i], k, 1);
		}
	}
	if (k == 0) d = n + 1;
	while (d % 10==0) {
		d /= 10;
	}
	printf("%d", d % 10);
}

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

fact.cpp: In function 'int pow(int, int, int)':
fact.cpp:6:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
fact.cpp: In function 'int main()':
fact.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
                        ^

#Verdict Execution timeMemoryGrader output
Fetching results...