結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー stngstng
提出日時 2022-08-17 11:32:29
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 886 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 102,300 KB
最終ジャッジ日時 2024-04-15 02:39:58
合計ジャッジ時間 4,792 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 34 ms
53,624 KB
testcase_02 AC 36 ms
54,460 KB
testcase_03 RE -
testcase_04 AC 37 ms
58,160 KB
testcase_05 RE -
testcase_06 AC 35 ms
53,492 KB
testcase_07 AC 34 ms
54,296 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 107 ms
93,100 KB
testcase_12 TLE -
testcase_13 AC 86 ms
87,744 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 TLE -
testcase_19 AC 1,755 ms
86,064 KB
testcase_20 RE -
権限があれば一括ダウンロードができます

ソースコード

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 == "+":
    print(kk)
    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)
    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