# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
22066 | 연습 세션과 본 대회의 등록은 왜 따로일까 (#42) | 다항식 계산 (KRIII5P_2) | C++98 | 0 ms | 8928 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
long long arr[1000010];
int main()
{
int n, p, i, j;
long long c, r;
scanf("%d%d", &n, &p);
for(i = n; i>=0; i--)
scanf("%lld", &arr[i]);
if(p == 2)
{
printf("%lld\n", arr[0]);
r = 0;
for(i = 0; i<=n; i++)
{
r += arr[i];
r %= p;
}
printf("%lld", r);
return 0;
}
for(i = p; i<=n; i++)
{
arr[i%p] += arr[i];
arr[i%p] %= p;
}
for(i = 0; i<p; i++)
{
c = 1;
r = 0;
for(j = 0; j<p; j++)
{
r += arr[j] * c;
c *= i;
r %= p;
c %= p;
}
printf("%lld\n", r);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |