結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2015-04-02 21:28:53 |
言語 | Ruby (3.4.1) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 421 bytes |
コンパイル時間 | 39 ms |
コンパイル使用メモリ | 7,680 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-06-26 04:51:55 |
合計ジャッジ時間 | 1,923 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 14 |
コンパイルメッセージ
Main.rb:21: warning: assigned but unused variable - n Syntax OK
ソースコード
class Fixnumdef power(x)result = 1n = selfwhile x > 0result = (result * n) % 1_000_003 if (x & 1).nonzero?n = (n * n) % 1_000_003x >>= 1endresultendendclass YukicoderEPS = 1_000_003def initializex, n = gets.chomp.split(' ').map(&:to_i)a = gets.chomp.split(' ').map(&:to_i)puts a.map{|i| x.power(i)}.inject(:+) % EPSendendYukicoder.new