Submission #169665


Source Code Expand

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

def key(list)
  list.map{|a,b| [a,b%2]}*","
end

def num(list)
  key = key(list)
  return @memo[key] if @memo[key]
  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)
  @memo[key]||=val+num(list)
  return @memo[key]
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 0
Code Size 684 Byte
Status TLE
Exec Time 2084 ms
Memory 24180 KB

Compile Error

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

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 0 / 99 0 / 1
Status
AC × 3
AC × 10
TLE × 10
AC × 10
TLE × 30
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 61 ms 4212 KB
sample_02.txt AC 56 ms 4212 KB
sample_03.txt AC 59 ms 4336 KB
subtask1_01.txt AC 55 ms 4212 KB
subtask1_02.txt AC 91 ms 4464 KB
subtask1_03.txt AC 56 ms 4212 KB
subtask1_04.txt TLE 2057 ms 22388 KB
subtask1_05.txt TLE 2057 ms 22256 KB
subtask1_06.txt AC 412 ms 7924 KB
subtask1_07.txt TLE 2080 ms 22632 KB
subtask1_08.txt AC 85 ms 4340 KB
subtask1_09.txt AC 59 ms 4212 KB
subtask1_10.txt TLE 2057 ms 22124 KB
subtask1_11.txt AC 95 ms 4468 KB
subtask1_12.txt TLE 2084 ms 21996 KB
subtask1_13.txt AC 65 ms 4332 KB
subtask1_14.txt AC 138 ms 4212 KB
subtask1_15.txt TLE 2060 ms 18944 KB
subtask1_16.txt TLE 2055 ms 21364 KB
subtask1_17.txt TLE 2056 ms 22128 KB
subtask1_18.txt AC 1697 ms 12140 KB
subtask1_19.txt TLE 2062 ms 21852 KB
subtask1_20.txt TLE 2064 ms 22132 KB
subtask2_01.txt TLE 2058 ms 22772 KB
subtask2_02.txt TLE 2031 ms 4336 KB
subtask2_03.txt TLE 2043 ms 13040 KB
subtask2_04.txt TLE 2046 ms 12660 KB
subtask2_05.txt TLE 2044 ms 15856 KB
subtask2_06.txt TLE 2046 ms 23412 KB
subtask2_07.txt TLE 2046 ms 22644 KB
subtask2_08.txt TLE 2041 ms 15348 KB
subtask2_09.txt TLE 2043 ms 15472 KB
subtask2_10.txt TLE 2041 ms 15216 KB
subtask2_11.txt TLE 2043 ms 15604 KB
subtask2_12.txt TLE 2042 ms 15704 KB
subtask2_13.txt TLE 2051 ms 17136 KB
subtask2_14.txt TLE 2041 ms 15596 KB
subtask2_15.txt TLE 2039 ms 15604 KB
subtask2_16.txt TLE 2044 ms 23796 KB
subtask2_17.txt TLE 2039 ms 15220 KB
subtask2_18.txt TLE 2051 ms 24180 KB
subtask2_19.txt TLE 2045 ms 24180 KB
subtask2_20.txt TLE 2044 ms 15220 KB