結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー stngstng
提出日時 2022-08-17 11:39:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,043 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 98,024 KB
最終ジャッジ日時 2024-04-15 02:43:59
合計ジャッジ時間 4,807 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 34 ms
52,724 KB
testcase_02 AC 34 ms
52,784 KB
testcase_03 WA -
testcase_04 AC 36 ms
58,240 KB
testcase_05 WA -
testcase_06 AC 34 ms
52,992 KB
testcase_07 AC 35 ms
52,864 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 121 ms
92,672 KB
testcase_12 TLE -
testcase_13 AC 97 ms
87,296 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 AC 1,722 ms
86,360 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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
    #print(bmod)
    exit()
    for i in range(n):
        tmp = k-(a[i]%k)
        if tmp in bmod:
            ans += bmod[tmp]
    print(ans)
else:
    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