結果

問題 No.167 N^M mod 10
ユーザー wing3196
提出日時 2015-03-20 01:01:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 565 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 80,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-22 01:09:14
合計ジャッジ時間 1,595 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<climits>
#include<functional>
#include<map>
#include<set>
#include<queue>
#include<cmath>
using namespace std;

signed main(){
	string N,M;
	cin>>N>>M;
	reverse(N.begin(),N.end());
	reverse(M.begin(),M.end());
	vector<int> latte;
	if(M[0]=='0'&&M.size()==1){
		puts("1");
		return 0;
	}
	if(M.size()==1) M += "0";
	int calc = 1, cnt = (M[1]-'0')*10+(M[0]-'0')+4;
	for(int i=0;i<cnt;i++) calc = calc*(N[0]-'0')%10;
	printf("%d\n",calc);
	return 0;
}
0