結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー akakimidori
提出日時 2017-04-24 12:49:39
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 11:49:48
合計ジャッジ時間 1,102 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:16:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |   scanf("%d",&m);
      |   ^~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int modPow(int r,int n,int mod){
  int ans=1;
  int t=r;
  while(n>0){
    ans=ans*(n&0x01?t:1)%mod;;
    t=t*t%mod;;
    n>>=1;
  }
  return ans;
}

void run(void){
  int m;
  scanf("%d",&m);
  const int n=2017;
  printf("%d\n",(n+modPow(n*n%m,n,m))%m);
  return;
}

int main(void){
  run();
  return 0;
}
0