結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
smiken_61
|
| 提出日時 | 2015-10-14 09:56:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 459 bytes |
| コンパイル時間 | 490 ms |
| コンパイル使用メモリ | 58,668 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-21 07:41:25 |
| 合計ジャッジ時間 | 1,383 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 WA * 3 |
ソースコード
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
using namespace std;
int pow(int m,int n){
int k=m;
for(int i=0;i<n-1;i++){
k=(k*m)%10;
}
return k;
}
int main() {
string s,t;
cin>>s>>t;
int m=atoi(s.substr(s.length()-1,1).c_str());
int l=t.length();
if(l<2){
if(t!="0"){
cout<<pow(m,atoi(t.substr(0,1).c_str()))<<endl;
}
else cout<<1<<endl;
}
else{
cout<<pow(m,atoi(t.substr(l-2,2).c_str())%4)<<endl;
}
return 0;
}
smiken_61