結果

問題 No.1201 お菓子配り-4
コンテスト
ユーザー 37zigen
提出日時 2020-08-30 07:44:56
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 3,709 ms / 4,000 ms
コード長 279 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 697 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 15,448 KB
最終ジャッジ日時 2026-05-10 03:17:36
合計ジャッジ時間 42,434 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import gcd
MOD=10**9+7
N=int(input())
M=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for a in A:
    for b in B:
        d=b//gcd(a,b)
        W=b
        H=W*a//b
        ans+=(H+1)*(W+1)-2*W+(W-1)//d
        ans%=MOD
print(ans)
0