結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | stng |
提出日時 | 2022-08-17 11:30:57 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 939 bytes |
コンパイル時間 | 289 ms |
コンパイル使用メモリ | 82,140 KB |
実行使用メモリ | 159,116 KB |
最終ジャッジ日時 | 2024-04-15 02:39:14 |
合計ジャッジ時間 | 5,204 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
60,492 KB |
testcase_01 | AC | 39 ms
53,812 KB |
testcase_02 | AC | 43 ms
54,312 KB |
testcase_03 | AC | 41 ms
53,280 KB |
testcase_04 | AC | 43 ms
59,044 KB |
testcase_05 | AC | 41 ms
54,736 KB |
testcase_06 | AC | 41 ms
52,452 KB |
testcase_07 | AC | 42 ms
53,116 KB |
testcase_08 | AC | 40 ms
53,216 KB |
testcase_09 | AC | 42 ms
54,396 KB |
testcase_10 | AC | 135 ms
151,568 KB |
testcase_11 | AC | 118 ms
93,008 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
ソースコード
def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors import math n,m,k = map(int,input().split()) opb = input().split() op = opb[0] b = [] for i in range(1,m+1): b.append(int(opb[i])) a = [int(input()) for i in range(n)] ans = 0 if op == "+": bmod = [0]*(k) for i in range(m): bmod[b[i]%k] += 1 #print(bmod) for i in range(n): ans += bmod[k-(a[i]%k)] print(ans) else: div = make_divisors(k) #print(div) #exit() bdiv = {} for i in div: tmp = 0 for j in range(m): if b[j]%i == 0: tmp += 1 bdiv[i] = tmp #print(tmp,i) #print(bdiv) for i in range(n): tmp = math.gcd(a[i],k) ans += bdiv[k//tmp] print(ans)