結果

問題 No.167 N^M mod 10
ユーザー fiordfiord
提出日時 2015-07-08 17:45:21
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 423 bytes
コンパイル時間 1,670 ms
コンパイル使用メモリ 144,984 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 09:36:50
合計ジャッジ時間 3,370 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 RE -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 17 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:2: warning: ‘mod’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(mod==0) mod=cnt;
  ^~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	string inn,m;	cin>>inn>>m;
	int n=(int)inn[(int)inn.size()-1]-'0';
	int lib[]={1,4,4,2,1,1,4,4,2};
	int cnt=lib[n-1];
	int mod;
	int size=(int)m.size();
	for(int i=0;i<size;i++){
		int num=(int)m[i]-'0';
		mod=num%cnt;
		if(i+1!=size)	m[i+1]+=mod*10;
	}
	if(mod==0)	mod=cnt;
	int ans=1;
	for(int i=0;i<mod;i++){
		ans=(ans*n)%10;
	}
	cout<<ans<<endl;
	return 0;
}
0