結果
問題 | No.16 累乗の加算 |
ユーザー |
|
提出日時 | 2015-06-22 13:50:18 |
言語 | PHP (7.2.24) |
結果 |
AC
|
実行時間 | 3,140 ms / 5,000 ms |
コード長 | 866 bytes |
コンパイル時間 | 1,741 ms |
コンパイル使用メモリ | 18,416 KB |
実行使用メモリ | 212,536 KB |
最終ジャッジ日時 | 2023-09-08 11:44:16 |
合計ジャッジ時間 | 31,180 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 436 ms
50,200 KB |
testcase_01 | AC | 432 ms
50,200 KB |
testcase_02 | AC | 3,139 ms
212,536 KB |
testcase_03 | AC | 2,864 ms
199,388 KB |
testcase_04 | AC | 2,408 ms
176,616 KB |
testcase_05 | AC | 2,951 ms
202,936 KB |
testcase_06 | AC | 2,835 ms
200,832 KB |
testcase_07 | AC | 1,979 ms
148,720 KB |
testcase_08 | AC | 2,997 ms
204,064 KB |
testcase_09 | AC | 1,754 ms
135,392 KB |
testcase_10 | AC | 1,510 ms
120,500 KB |
testcase_11 | AC | 3,140 ms
212,352 KB |
testcase_12 | AC | 3,096 ms
211,168 KB |
testcase_13 | AC | 16 ms
19,036 KB |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php define("EXP_MAX", 100000000); define("RESULT_DIV_VALUE", 1000003); list($x, $n) = explode(" ",trim(fgets(STDIN))); $exp_member_array = explode(" ",trim(fgets(STDIN))); $exp_sum_value = array(); $exp_sum_value[1] = intval($x); $gmp_pow_temp = gmp_init($exp_sum_value[1]); for ( $i=2; $i<=EXP_MAX; $i<<=1 ) { $gmp_pow_temp = gmp_pow($gmp_pow_temp, 2); $exp_sum_value[$i] = gmp_intval(gmp_div_r($gmp_pow_temp, gmp_init(RESULT_DIV_VALUE))); } $exp_sum_value_max_index = ($i>>1); $sum = 0; foreach ( $exp_member_array as &$exp ) { $i = $exp_sum_value_max_index; $gmp_sum_temp = gmp_init(1); while ( $exp > 0 ) { while ( $exp >= $i ) { $exp -= $i; $gmp_sum_temp = gmp_mul($gmp_sum_temp, $exp_sum_value[$i]); } $i >>= 1; } $sum += gmp_intval(gmp_div_r($gmp_sum_temp, gmp_init(RESULT_DIV_VALUE))); $sum %= RESULT_DIV_VALUE; } echo $sum.PHP_EOL;