結果
| 問題 |
No.473 和と積の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-23 02:10:41 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 704 bytes |
| コンパイル時間 | 2,598 ms |
| コンパイル使用メモリ | 77,044 KB |
| 実行使用メモリ | 399,940 KB |
| 最終ジャッジ日時 | 2024-12-16 02:58:43 |
| 合計ジャッジ時間 | 44,399 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 TLE * 8 |
ソースコード
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
def divisors(n):
sq = int(n ** .5)
res = [(i, n//i) for i in range(2, sq+1) if n%i==0]
return res
N, x = map(int, raw_input().split())
sett = set()
seen = set()
def rec(n, arr):
global sett
key = tuple(sorted(arr))
if n == N:
sett.add(key)
return
# arr.sort()
if key in seen:
return
seen.add(key)
for i in xrange(n):
x = arr[i]
arr.pop(i)
divs = divisors(x+1)
for p, q in divs:
arr.append(p-1)
arr.append(q-1)
rec(n+1, arr)
arr.pop()
arr.pop()
arr.insert(i, x)
rec(1, [x])
print len(sett)