Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #1397714

Source Code Expand

Copy
```class Integer
@@fact
@@factinv
@@mod
def self.init_fact(max,mod)
@@mod=mod
@@fact=(2..max).inject([1,1]){|s,r|s+[s[-1]*r%mod]}
@@factinv=[1,1]
@@factinv[max]=@@fact[max].pow({},mod-2)%mod
(max-1).downto(1){|i|
@@factinv[i]=@@factinv[i+1]*(i+1)%mod
}
end
def pow(memo,n)
return 1 if n==0
return memo[n] if memo[n]
memo[n] = pow(memo,n/2)*pow(memo,n/2)*(n%2==0?1:self)%@@mod
end
def combination(k)
return 0 if self < k
@@fact[self]*@@factinv[k]*@@factinv[self-k]%@@mod
#self.factorial/(k.factorial*(self-k).factorial)
end

def permutation(k)
self.factorial/(self-k).factorial
end

def factorial
return 1 if self == 0
(1..self).inject(:*)
end
end

n=gets.to_i
a=gets.split.map(&:to_i)
dup=(1..n).find{|i|a.count(i)>1}
l,r=[a.index(dup),a.rindex(dup)]
Integer.init_fact(100000,1000000007)
puts (1..n+1).map{|i|((n+1).combination(i)-(l+n-r).combination(i-1))%1000000007}
```

#### Submission Info

Submission Time 2017-07-02 01:05:17+0900 D - 11 mayumini Ruby (2.3.3) 0 998 Byte TLE 2115 ms 180980 KB

#### Compile Error

```./Main.rb:2: warning: possibly useless use of a variable in void context
./Main.rb:3: warning: possibly useless use of a variable in void context
./Main.rb:4: warning: possibly useless use of a variable in void context
```

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 0 / 600 1.txt, mx.txt, rnd_0.txt, rnd_1.txt, rnd_2.txt, rnd_3.txt, rnd_4.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt 2108 ms 8076 KB
mx.txt 2108 ms 8076 KB
rnd_0.txt 2108 ms 7052 KB
rnd_1.txt 2108 ms 6284 KB
rnd_2.txt 2108 ms 2940 KB
rnd_3.txt 2107 ms 2684 KB
rnd_4.txt 2108 ms 3452 KB
sample1.txt 2115 ms 154504 KB
sample2.txt 2115 ms 158968 KB
sample3.txt 2113 ms 180980 KB