結果

問題 No.167 N^M mod 10
ユーザー mmn15277198
提出日時 2020-06-13 16:30:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 995 ms
コンパイル使用メモリ 93,884 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 14:12:58
合計ジャッジ時間 2,081 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e6+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	long long n,m;
	cin >> n >> m;
	long long now=1;
	vector<int> a;
	for(long long i=0;i<10;i++){
		now*=n%10;
		now%=10;
		a.push_back(now);
	}

	int dist=1;
	for(int i=0;i<a.size();i++){
		if(i==0)continue;
		if(a[i]==a[0]){
			break;
		}else{
			dist++;
		}
	}
	int id=m%dist-1;
	if(id<0)id=0;
	int ans=a[id];
	cout << ans << endl;
	return 0;
}
0