結果

問題 No.167 N^M mod 10
ユーザー Lay_ec
提出日時 2015-03-20 01:18:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 23:39:46
合計ジャッジ時間 1,425 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

	int res=1;
	for(int i=0;i<y;i++){ res*=x; res%=10;}

	if(y==0) res=0;
	cout<<res<<endl;

	return 0;
}
0