Submission #169522


Source Code Expand

Copy
#!/usr/bin/env ruby
def kai(n)
  (1..n).to_a.inject(1){|r, i| r * i}
end

def num(list)
  return list[0][1] % 2 if list.size == 1
  (list.size-1).downto(1) {|i|
    list[i][1]+=1 if list[i][0] % list[0][0] == 0
  }
  val = list[0][1] % 2
  list.delete_at(0)
  return val + num(list)
end

coins=[]
N=gets.to_i
N.times{ coins << gets.to_i }

total=0.0
coins.permutation() {|perm|
  list=[]
  perm.each {|item| list << [item, 1] }
  ans = num(list)
  total += ans
  #puts "#{perm} count:#{ans}"
}
puts (total/kai(N))

Submission Info

Submission Time
Task C - コイン
User hoi
Language Ruby (1.9.3)
Score 99
Code Size 540 Byte
Status TLE
Exec Time 2034 ms
Memory 4484 KB

Compile Error

./Main.rb:28: warning: (...) interpreted as grouped expression

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 99 / 99 0 / 1
Status
AC × 3
AC × 20
AC × 20
TLE × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt
Case Name Status Exec Time Memory
sample_01.txt AC 62 ms 4256 KB
sample_02.txt AC 56 ms 4128 KB
sample_03.txt AC 58 ms 4260 KB
subtask1_01.txt AC 62 ms 4132 KB
subtask1_02.txt AC 67 ms 4392 KB
subtask1_03.txt AC 56 ms 4132 KB
subtask1_04.txt AC 525 ms 4392 KB
subtask1_05.txt AC 533 ms 4260 KB
subtask1_06.txt AC 118 ms 4384 KB
subtask1_07.txt AC 476 ms 4260 KB
subtask1_08.txt AC 61 ms 4380 KB
subtask1_09.txt AC 57 ms 4132 KB
subtask1_10.txt AC 531 ms 4424 KB
subtask1_11.txt AC 60 ms 4384 KB
subtask1_12.txt AC 485 ms 4384 KB
subtask1_13.txt AC 64 ms 4140 KB
subtask1_14.txt AC 126 ms 4388 KB
subtask1_15.txt AC 587 ms 4388 KB
subtask1_16.txt AC 486 ms 4388 KB
subtask1_17.txt AC 598 ms 4388 KB
subtask1_18.txt AC 591 ms 4252 KB
subtask1_19.txt AC 575 ms 4388 KB
subtask1_20.txt AC 573 ms 4380 KB
subtask2_01.txt TLE 2034 ms 4392 KB
subtask2_02.txt TLE 2033 ms 4388 KB
subtask2_03.txt TLE 2032 ms 4392 KB
subtask2_04.txt TLE 2032 ms 4388 KB
subtask2_05.txt TLE 2032 ms 4384 KB
subtask2_06.txt TLE 2034 ms 4384 KB
subtask2_07.txt TLE 2033 ms 4384 KB
subtask2_08.txt TLE 2032 ms 4484 KB
subtask2_09.txt TLE 2034 ms 4388 KB
subtask2_10.txt TLE 2031 ms 4388 KB
subtask2_11.txt TLE 2031 ms 4392 KB
subtask2_12.txt TLE 2032 ms 4396 KB
subtask2_13.txt TLE 2033 ms 4392 KB
subtask2_14.txt TLE 2030 ms 4380 KB
subtask2_15.txt TLE 2033 ms 4388 KB
subtask2_16.txt TLE 2032 ms 4380 KB
subtask2_17.txt TLE 2034 ms 4384 KB
subtask2_18.txt TLE 2032 ms 4352 KB
subtask2_19.txt TLE 2033 ms 4392 KB
subtask2_20.txt TLE 2034 ms 4396 KB