結果
問題 | No.251 大きな桁の復習問題(1) |
ユーザー |
![]() |
提出日時 | 2019-06-04 05:32:53 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 1,006 bytes |
コンパイル時間 | 667 ms |
コンパイル使用メモリ | 104,024 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-22 01:32:37 |
合計ジャッジ時間 | 1,504 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import std.algorithm;import std.array;import std.conv;import std.math;import std.range;import std.stdio;import std.string;import std.typecons;void scan(T...)(ref T a) {string[] ss = readln.split;foreach (i, t; T) a[i] = ss[i].to!t;}T read(T)() { return readln.chomp.to!T; }T[] reads(T)() { return readln.split.to!(T[]); }alias readint = read!int;alias readints = reads!int;const MOD = 129402307;long modulo(string s, long m) {long x = 0;foreach (d; s.map!(c => c - '0')) {x = (10 * x + d) % m;}return x;}long modPow(long x, long k, long m) {if (k == 0) return 1;if (k % 2 == 0) return modPow(x * x % m, k / 2, m);return x * modPow(x, k - 1, m) % m;}long calc(string s, string t) {long a = modulo(s, MOD);long b = modulo(t, MOD - 1);if (t == "0") return 1;if (a == 0) return 0;return modPow(a, b, MOD);}void main() {string s = read!string;string t = read!string;writeln(calc(s, t));}