結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2015-03-20 00:35:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 745 bytes |
コンパイル時間 | 586 ms |
コンパイル使用メモリ | 81,532 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-28 23:35:44 |
合計ジャッジ時間 | 1,462 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 16 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <cmath> #include <algorithm> #include <cstdlib> #include <ctime> #include <cstdio> #include <functional> #include <set> #include <sstream> #include <map> #include <queue> #include <stack> using namespace std; int mod(string m,int x) { int res=0; for(int i=0;i<m.size();i++){ res=(res*10+m[i]-'0')%x; } return res; } int main() { string n,m; cin>>n>>m; string loop[10]; loop[2]="2486"; loop[3]="3971"; loop[4]="46"; loop[7]="7931"; loop[8]="8426"; loop[9]="91"; int x=n[n.size()-1]-'0'; switch(x){ case 0: case 1: case 5: case 6: cout<<x<<endl; return 0; } // cout<<x<<" "<<mod(m,x)<<endl; cout<<loop[x][(mod(m,x)+1)%x]<<endl; return 0; }