답안 #22223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22223 2017-04-30T02:22:20 Z a(#1038, wimzzang) 다항식 계산 (KRIII5P_2) C++
0 / 7
0 ms 2020 KB
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int P;
int fMOD_P(const vector<int> &a, const int x) {
	int xPow = 1;
	int fx = 0;
	for (int i = 0; i < a.size(); i++) {
		fx = (fx + a[i] * xPow) % P;
		xPow = (xPow*x) % P;
	}
	return fx;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//setbuf(stdout, NULL);
	int testCase; cin >> testCase;
	for (int t = 1; t <= testCase; t++)
	{
		int N; cin >> N >> P;
		vector<int> a(N+1);
		for (int i = N; i >= 0; i--) {
			cin >> a[i];
			a[i] = a[i] % P;
		}
		cout << "testCase" << t << endl;
		for (int i = 0; i < P; i++)
			cout << fMOD_P(a, i) << endl;

	}
	return 0;
}

Compilation message

pc.cpp: In function 'int fMOD_P(const std::vector<int>&, int)':
pc.cpp:11:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.size(); i++) {
                    ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2020 KB Output isn't correct
2 Halted 0 ms 0 KB -