結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2015-04-02 21:26:15 |
| 言語 | Ruby (3.4.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 382 bytes |
| コンパイル時間 | 35 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-07-03 23:34:17 |
| 合計ジャッジ時間 | 1,786 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 14 |
コンパイルメッセージ
Main.rb:21: warning: assigned but unused variable - n Syntax OK
ソースコード
class Fixnum
def power(x)
result = 1
n = self
while x > 0
result *= n if (x & 1).nonzero?
n *= n
x >>= 1
end
result
end
end
class Yukicoder
EPS = 1_000_003
def initialize
x, n = gets.chomp.split(' ').map(&:to_i)
a = gets.chomp.split(' ').map(&:to_i)
puts a.map{|i| x.power(i)}.inject(:+) % EPS
end
end
Yukicoder.new
siman