답안 #74449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74449 2018-09-02T03:20:07 Z TAMREF 다항식 계산 (KRIII5P_2) C++11
0 / 7
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll a[1005];
int n, p, a0;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> p;
	for(int i = n, x; i >= 0; i--){
		cin >> x;
		a[i % p] += x;
		if(!i) a0 = x;
	}
	for(int i = p; i--;) a[i] %= p;
	for(int j = 0; j < p; j++){
		if(!j){
			printf("%d\n",a0);
			continue;
		}
		int k = 1;
		int ans = 0;
		for(int i = 0; i <= p; i++){
			ans = (ans + k * a[i]) % p;
			k = k * j % p;
		}
		printf("%d\n",ans);
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -