답안 #22166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22166 2017-04-29T13:43:20 Z 스팟보드CSS가깨져요(#1029, imsifile) 다항식 계산 (KRIII5P_2) C++
7 / 7
229 ms 1124 KB
#include<stdio.h>

int N, P, ba[2222];

int main(){
	scanf("%d%d", &N, &P);
	for(int i=N; i>=0; i--){
		int a, i2 = i%(P-1);
		scanf("%d", &a), a%=P;
		if(i2 == 0 && i != 0)i2 = P-1;
		ba[i2] += a;
	}
	for(int i=0; i<P; i++)ba[i] %= P;
	for(int i=0; i<P; i++){
		int sum=0, jg=1;
		for(int j=0; j<P; j++){
			sum += jg*ba[j]; sum %= P;
			jg *= i; jg %= P;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Compilation message

pc.cpp: In function 'int main()':
pc.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &P);
                       ^
pc.cpp:9:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a), a%=P;
                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1124 KB Output is correct
2 Correct 0 ms 1124 KB Output is correct
3 Correct 0 ms 1124 KB Output is correct
4 Correct 0 ms 1124 KB Output is correct
5 Correct 0 ms 1124 KB Output is correct
6 Correct 13 ms 1124 KB Output is correct
7 Correct 13 ms 1124 KB Output is correct
8 Correct 13 ms 1124 KB Output is correct
9 Correct 13 ms 1124 KB Output is correct
10 Correct 9 ms 1124 KB Output is correct
11 Correct 6 ms 1124 KB Output is correct
12 Correct 9 ms 1124 KB Output is correct
13 Correct 3 ms 1124 KB Output is correct
14 Correct 0 ms 1124 KB Output is correct
15 Correct 0 ms 1124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1124 KB Output is correct
2 Correct 0 ms 1124 KB Output is correct
3 Correct 0 ms 1124 KB Output is correct
4 Correct 0 ms 1124 KB Output is correct
5 Correct 0 ms 1124 KB Output is correct
6 Correct 13 ms 1124 KB Output is correct
7 Correct 13 ms 1124 KB Output is correct
8 Correct 13 ms 1124 KB Output is correct
9 Correct 13 ms 1124 KB Output is correct
10 Correct 9 ms 1124 KB Output is correct
11 Correct 6 ms 1124 KB Output is correct
12 Correct 9 ms 1124 KB Output is correct
13 Correct 3 ms 1124 KB Output is correct
14 Correct 0 ms 1124 KB Output is correct
15 Correct 0 ms 1124 KB Output is correct
16 Correct 219 ms 1124 KB Output is correct
17 Correct 193 ms 1124 KB Output is correct
18 Correct 189 ms 1124 KB Output is correct
19 Correct 186 ms 1124 KB Output is correct
20 Correct 186 ms 1124 KB Output is correct
21 Correct 193 ms 1124 KB Output is correct
22 Correct 229 ms 1124 KB Output is correct
23 Correct 193 ms 1124 KB Output is correct
24 Correct 183 ms 1124 KB Output is correct
25 Correct 183 ms 1124 KB Output is correct
26 Correct 193 ms 1124 KB Output is correct
27 Correct 193 ms 1124 KB Output is correct
28 Correct 186 ms 1124 KB Output is correct
29 Correct 189 ms 1124 KB Output is correct
30 Correct 179 ms 1124 KB Output is correct