結果

問題 No.251 大きな桁の復習問題(1)
ユーザー krotonkroton
提出日時 2015-07-23 01:35:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 640 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 53,340 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 16:45:32
合計ジャッジ時間 1,688 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;
const int MOD = 129402307;

int mod(const string& S, int m){
	int res = 0;
	for(char x : S){
		res *= 10;
		res += x - '0';
		res %= m;
	}
	return res;
}

ll mod_pow(ll x, ll e, ll m){
	ll v = 1;
	for(;e;e>>=1){
		if(e & 1){
			v = (v * x) % m;
		}
		x = (x * x) % m;
	}
	return v;
}

int main(){
	string N, M;
	cin >> N >> M;

	if(N == "0"){
		cout << 0 << endl;
		return 0;
	}
	if(M == "0"){
		cout << 1 << endl;
		return 0;
	}
	int n = mod(N, MOD);
	if(n == 0){
		cout << 0 << endl;
		return 0;
	}
	int m = mod(M, MOD - 1);
	cout << mod_pow(n, m, MOD) << endl;
	return 0;
}
0