結果
問題 | No.389 ロジックパズルの組み合わせ |
ユーザー |
![]() |
提出日時 | 2016-07-08 23:25:03 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 558 ms / 2,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 1,652 ms |
コンパイル使用メモリ | 76,280 KB |
実行使用メモリ | 114,500 KB |
最終ジャッジ日時 | 2024-10-13 07:11:55 |
合計ジャッジ時間 | 15,618 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 99 |
ソースコード
def modpow(s,q,mod): ret = 1 while q > 0: if q % 2 == 1: ret = (s * ret) % mod s = (s * s) % mod q = q/2 return ret x = input() a = map(int,raw_input().split()) for i in xrange(len(a)): x = x - a[i] + 1 if a[0] == 0: print 1 elif x < len(a)+len(a)-1: print "NA" else: b = len(a)+1 c = x-len(a)-len(a)+1 d = 1 for i in xrange(b,b+c): d *= i d %= 1000000007 for i in xrange(1,c+1): d *= modpow(i,1000000005,1000000007) d %= 1000000007 print d