結果

問題 No.167 N^M mod 10
ユーザー hotpepsi
提出日時 2015-10-02 01:28:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 378 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 55,384 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 19:02:16
合計ジャッジ時間 1,737 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <cstdio>

using namespace std;

typedef long long LL;

LL modpow(LL x, LL n, LL mod)
{
	LL a = 1;
	for (LL k = x; n > 0; n >>= 1, k = (k*k) % mod) {
		if (n & 1) {
			a = (a*k) % mod;
		}
	}
	return a;
}

int main(int argc, char *argv[])
{
	int N, M;
	cin >> N >> M;
	LL ans = modpow(N, M, 10);
	cout << ans << endl;
	return 0;
}
0