# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22063 | 아재 goto 써요? (#42) | 다항식 계산 (KRIII5P_2) | C++14 | 369 ms | 8252 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// =====================================================================================
//
// Filename: pc.cpp
// Created: 2017년 04월 29일 15시 32분 37초
// Compiler: g++ -O2 -std=c++14
// Author: baactree , bsj0206@naver.com
// Company: Chonnam National University
//
// =====================================================================================
#include <bits/stdc++.h>
using namespace std;
int n, p;
int arr[1001];
vector<int> temp;
int _pow(int a, int b){
if(b==0)
return 1;
int temp=_pow(a, b/2);
temp=(temp*temp)%p;
if(b&1)
return (temp*a)%p;
return temp;
}
int main(){
scanf("%d%d", &n, &p);
for(int i=0;i<n+1;i++){
int in;
scanf("%d", &in);
temp.push_back(in);
}
reverse(temp.begin(), temp.end());
for(int i=0, idx=0;i<n+1;i++, idx++){
if(idx==p)
idx=1;
int in=temp[i];
arr[idx]=(arr[idx]+in)%p;
}
for(int i=0;i<p;i++){
int ans=0;
for(int j=0;j<p;j++){
ans+=_pow(i, j)*arr[j];
ans%=p;
}
printf("%d\n", ans);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |