제출 #22154

#제출 시각아이디문제언어결과실행 시간메모리
22154_(:3」∠)_ (#42)다항식 계산 (KRIII5P_2)C++11
7 / 7
239 ms1120 KiB
#include <cstdio>

int A[1010];

int main(){
  int N, P; scanf("%d%d", &N, &P);

  for(int i = N; i > 0; i--){
    int x; scanf("%d", &x); x %= P;

    int i_ = i % (P - 1); A[i_] += x;
    if(A[i_] >= P) A[i_] -= P;
  }

  int x0; scanf("%d", &x0); x0 %= P;
  printf("%d\n", x0);

  A[0] += x0; if(A[0] >= P) A[0] -= P;

  for(int x = 1; x < P; x++){
    int v = 1, s = 0;

    for(int o = 0; o < P - 1; o++){
      s += A[o] * v % P; if(s >= P) s -= P;
      v *= x; v %= P;
    }

    printf("%d\n", s);
  }
  return 0;
}

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

pc.cpp: In function 'int main()':
pc.cpp:6:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int N, P; scanf("%d%d", &N, &P);
                                  ^
pc.cpp:9:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int x; scanf("%d", &x); x %= P;
                           ^
pc.cpp:15:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x0; scanf("%d", &x0); x0 %= P;
                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...