結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー stngstng
提出日時 2022-08-17 11:49:09
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,033 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 98,304 KB
最終ジャッジ日時 2024-04-15 02:49:52
合計ジャッジ時間 2,633 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,624 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 35 ms
53,212 KB
testcase_04 RE -
testcase_05 AC 34 ms
53,296 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 35 ms
53,328 KB
testcase_09 AC 36 ms
53,920 KB
testcase_10 AC 93 ms
87,512 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 109 ms
88,660 KB
testcase_15 AC 91 ms
80,488 KB
testcase_16 AC 103 ms
86,220 KB
testcase_17 AC 81 ms
80,252 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 134 ms
98,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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):
        tmp = b[i]%k
        #print(bmod,tmp)
        if tmp in bmod:
            bmod[tmp] += 1
        else:
            bmod[tmp] = 1
    for i in range(n):
        tmp = (k-(a[i]%k))%k
        if tmp in bmod:
            ans += bmod[tmp]
    print(ans)
else:
    print(kk)
    div = make_divisors(k)
    bdiv = {}
    for i in div:
        tmp = 0
        for j in range(m):
            if b[j]%i == 0:
                tmp += 1
        bdiv[i] = tmp
    for i in range(n):
        tmp = math.gcd(a[i],k)
        ans += bdiv[k//tmp]

    print(ans)
0