結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 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 Fixnum
def power(x)
result = 1
n = self
while x > 0
result = (result * n) % 1_000_003 if (x & 1).nonzero?
n = (n * n) % 1_000_003
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