結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,328 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 35 ms
54,028 KB
testcase_04 RE -
testcase_05 AC 34 ms
53,124 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 36 ms
52,788 KB
testcase_09 AC 34 ms
53,516 KB
testcase_10 AC 91 ms
87,836 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 100 ms
86,248 KB
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 133 ms
98,424 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)
        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