結果

問題 No.1972 Modulo Set
ユーザー candy-con
提出日時 2022-06-10 22:56:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 837 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 13,560 KB
最終ジャッジ日時 2024-09-21 06:44:33
合計ジャッジ時間 3,221 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools 
N, M = map(int,input().split())
Set_N = [int(input()) for _ in range(N)]
subset = []
set_2 = []
not_candidates = []
set_length = []
if len(Set_N) == 1:
  print(1)
else:
  for i in range(1,N+1):
    for j in itertools.combinations(Set_N,i):
      subset.append(list(j))
  for i in subset:
    if len(i) == 1:
      pass
    else:
      for pair in itertools.combinations(i,2):
        for k in range(1,len(Set_N)+1):
          if M >= sum(pair):
            if M % sum(pair) != 0:
              set_2.append(i)
          elif M < sum(pair):
            if sum(pair) % M != 0:
              set_2.append(i)
          if len(i) == k and (M % sum(pair) == 0 or sum(pair) % M == 0):
            not_candidates.append(i)
  for i in set_2:
    if i not in not_candidates:
      set_length.append(len(i))
print(max(set_length))
0