結果

問題 No.16 累乗の加算
ユーザー zazaboonzazaboon
提出日時 2017-02-05 18:49:53
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 293 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 11,404 KB
実行使用メモリ 15,260 KB
最終ジャッジ日時 2023-08-25 22:47:12
合計ジャッジ時間 2,178 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,260 KB
testcase_01 WA -
testcase_02 AC 82 ms
15,172 KB
testcase_03 AC 80 ms
15,108 KB
testcase_04 AC 81 ms
15,220 KB
testcase_05 AC 81 ms
15,216 KB
testcase_06 AC 81 ms
15,252 KB
testcase_07 AC 80 ms
15,244 KB
testcase_08 AC 81 ms
15,240 KB
testcase_09 AC 82 ms
15,140 KB
testcase_10 AC 80 ms
15,148 KB
testcase_11 AC 79 ms
15,108 KB
testcase_12 AC 80 ms
15,156 KB
testcase_13 AC 80 ms
15,204 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:12: warning: assigned but unused variable - p
Syntax OK

ソースコード

diff #

def k2(k)
  return $n if(k <= 1)
  ans = 1
  if((k%2) == 0)
    ans *= k2(k/2)**2
  else
    ans *= k2(k-1)
    ans *= $n
  end
  return ans % $m
end
$n,p = gets.chomp.split(" ").map{|u|u.to_i}
$m = 1000003
t = gets.chomp.split(" ").map{|u|u.to_i}
a = 0
t.each do |d|
  a += k2(d)
end
p a % $m
0