結果

問題 No.167 N^M mod 10
ユーザー 沙耶花
提出日時 2021-11-03 12:33:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 418 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 193,264 KB
最終ジャッジ日時 2025-01-25 10:52:59
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 5000000000000000000



int main(){	
	
	string s,t;
	cin>>s>>t;
	
	int N = 0,M = 0;
	rep(i,s.size()){
		N *= 10;
		N += s[i]-'0';
		N %= 10;
	}
	rep(i,t.size()){
		M *= 10;
		M += t[i]-'0';
		M %= 2520;
	}
	
	int ans = 1;
	rep(i,M){
		ans *= N;
		ans %= 10;
	}
	cout<<ans<<endl;
	
	return 0;
	
}
0