結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
Lay_ec
|
| 提出日時 | 2015-03-20 01:24:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 524 bytes |
| コンパイル時間 | 598 ms |
| コンパイル使用メモリ | 81,736 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-22 01:09:41 |
| 合計ジャッジ時間 | 1,544 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
#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 main()
{
string n,m;
cin>>n>>m;
int x=n[n.size()-1]-'0',y=m[m.size()-1]-'0';
if(m.size()!=1) y+=(m[m.size()-2]-'0')*10;
y%=4;
if(y==0 && m!="0") y=4;
int res=1;
for(int i=0;i<y;i++){ res*=x; res%=10;}
cout<<res<<endl;
return 0;
}
Lay_ec