結果
問題 | No.16 累乗の加算 |
ユーザー | watarimaycry2 |
提出日時 | 2019-12-09 22:38:40 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 992 bytes |
コンパイル時間 | 2,331 ms |
コンパイル使用メモリ | 71,908 KB |
実行使用メモリ | 56,496 KB |
最終ジャッジ日時 | 2023-09-05 11:42:16 |
合計ジャッジ時間 | 5,040 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
56,168 KB |
testcase_01 | AC | 124 ms
56,188 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 124 ms
55,756 KB |
testcase_12 | WA | - |
testcase_13 | AC | 131 ms
55,520 KB |
ソースコード
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static void myout(Object t){System.out.println(t);} static String getStr(){return sc.next();} static int getInt(){return sc.nextInt();} static Long getLong(){return sc.nextLong();} static boolean isNext(){return sc.hasNext();} public static void main(String[] args){ long x = getLong(); long N = getLong(); int mod = 1000003; long output = 0; for(int i = 0; i < N; i++){ output += originPow(x,getLong(),mod); } myout(output); } //便利メソッド追加枠ここから static long originPow(long x, long n,int m) { long ans = 1; while (n > 0) { if ((n & 1) == 1)ans = ans * x % m; x = x * x % m; n >>= 1; } return ans; } //便利メソッド追加枠ここまで }