제출 #22138

#제출 시각아이디문제언어결과실행 시간메모리
22138연습대회 팀 네임은 수정할 수 있을까? (#42)다항식 계산 (KRIII5P_2)C++14
7 / 7
209 ms5024 KiB
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <string.h>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;

const int MAX_N = 1e6 + 100, MAX_P = 1e3 + 100;

int N, P, Nr[MAX_N], Ans[MAX_P];
int main() {
	scanf("%d%d", &N, &P); for(int i=N; i>=0; i--) scanf("%d", &Nr[i]), Nr[i] %= P;
	Ans[0] = Nr[0];
	for(int i=N; i>=P-1; i--) Nr[i-(P-1)] = (Nr[i-(P-1)] + Nr[i]) % P;
	for(int x=1; x<P; x++) {
		int pw = 1, &ans = Ans[x];
		for(int i=0; i<P-1; i++) {
			ans = (ans + pw * Nr[i]) % P;
			pw = pw * x % P;
		}
	}
	for(int i=0; i<P; i++) printf("%d\n", Ans[i]);
	return 0;
}

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

pc.cpp: In function 'int main()':
pc.cpp:20:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &P); for(int i=N; i>=0; i--) scanf("%d", &Nr[i]), Nr[i] %= P;
                       ^
pc.cpp:20:80: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &P); for(int i=N; i>=0; i--) scanf("%d", &Nr[i]), Nr[i] %= P;
                                                                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...