結果

問題 No.167 N^M mod 10
ユーザー itezpaceitezpace
提出日時 2016-09-17 11:24:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 56,116 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 15:17:45
合計ジャッジ時間 1,474 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
6,940 KB
testcase_16 WA -
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
6,940 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
const int mod=10;

int ary[9][4]={
  {1,1,1,1},
  {2,4,8,6},
  {3,9,7,1},
  {4,6,4,6},
  {5,5,5,5},
  {6,6,6,6},
  {7,9,3,1},
  {8,4,2,6},
  {9,1,9,1}
};

int main(){
  string n,m;
  cin>>n;
  cin>>m;
  int a=n[n.size()-1]-'0';
  int c=0, d=0;
  for(int i=0; i<m.size(); ++i){
    int b=m[i]-'0';
    if(c+b<10){
      c+=b;
    } else {
      c+=b;
      c-=10;
      d+=1;
    }
  }
  int e=c%4;
  int f=d%4;
  int g=e+f;
  g%=4;
  if(g==3) g=-1;
  cout<<ary[a-1][g+1]<<endl;
  return 0;
}
0