結果
問題 | No.251 大きな桁の復習問題(1) |
ユーザー | Grenache |
提出日時 | 2015-07-25 00:16:51 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,841 bytes |
コンパイル時間 | 3,665 ms |
コンパイル使用メモリ | 75,756 KB |
実行使用メモリ | 61,544 KB |
最終ジャッジ日時 | 2023-09-23 02:51:17 |
合計ジャッジ時間 | 11,078 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
49,408 KB |
testcase_01 | AC | 44 ms
49,588 KB |
testcase_02 | AC | 44 ms
49,664 KB |
testcase_03 | AC | 44 ms
49,560 KB |
testcase_04 | AC | 44 ms
48,036 KB |
testcase_05 | AC | 44 ms
49,420 KB |
testcase_06 | AC | 43 ms
49,788 KB |
testcase_07 | AC | 44 ms
49,412 KB |
testcase_08 | AC | 43 ms
49,544 KB |
testcase_09 | TLE | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.Arrays; import java.util.Iterator; public class Main_yukicoder251 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int MOD = 129402307; BigInteger TWO = new BigInteger("2"); String n = sc.next(); String m = sc.next(); BigInteger nn = new BigInteger(n); nn = nn.mod(new BigInteger("129402307")); BigInteger loop = new BigInteger(m); long x = nn.longValue(); long ret = 1; while (loop.compareTo(BigInteger.ZERO) > 0) { if (loop.mod(TWO).compareTo(BigInteger.ONE) == 0) { ret = ret * x % MOD; } x = x * x % MOD; loop = loop.divide(TWO); } System.out.println(ret); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } }