Submission #20252

# Submission time Handle Problem Language Result Execution time Memory
20252 2016-09-08T06:54:25 Z gamebaboo 팩토리얼 세제곱들의 합 (YDX14_fact) C++
0 / 1
2 ms 0 KB
#include <stdio.h>
#include <math.h>

int main(){

	int a, k, n, t, s;
	scanf("%d", &n);
	scanf("%d", &k);

	s = 0;
	for (; ; n--)
	{
		if (n == 0)
		{
			s += 1;
			break;
		}
		else
		{
			for (t = n, a = n; t > 1; t--)
			{
				a *= (t - 1);
			}
			s += pow(a,k);
		}
		s %= 10;
	}

	printf("%d\n", s==10 ? 1:s);
	
	// 1 1 2 6 24

}

Compilation message

fact.cpp: In function 'int main()':
fact.cpp:7:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
fact.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &k);
                 ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 0 KB answer is '4'
2 Correct 2 ms 0 KB answer is '2'
3 Correct 1 ms 0 KB answer is '2'
4 Correct 1 ms 0 KB answer is '2'
5 Correct 1 ms 0 KB answer is '2'
6 Correct 1 ms 0 KB answer is '4'
7 Correct 2 ms 0 KB answer is '6'
8 Correct 1 ms 0 KB answer is '1'
9 Correct 1 ms 0 KB answer is '2'
10 Correct 1 ms 0 KB answer is '6'
11 Correct 1 ms 0 KB answer is '4'
12 Incorrect 1 ms 0 KB expected '5', found '1'