結果

問題 No.487 2017 Calculation(2017の計算)
コンテスト
ユーザー akakimidori
提出日時 2017-04-24 12:49:39
言語 C90
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 326 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 192 ms
コンパイル使用メモリ 38,684 KB
最終ジャッジ日時 2026-02-24 00:37:30
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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