結果
問題 | No.1201 お菓子配り-4 |
ユーザー | tamato |
提出日時 | 2020-08-28 22:50:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,019 ms / 4,000 ms |
コード長 | 630 bytes |
コンパイル時間 | 447 ms |
コンパイル使用メモリ | 82,684 KB |
実行使用メモリ | 63,796 KB |
最終ジャッジ日時 | 2024-11-14 01:42:55 |
合計ジャッジ時間 | 13,550 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys from math import gcd input = sys.stdin.readline 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: c, d = divmod(a, b) ans = (ans + ((c * b)%mod * (b+1))%mod)%mod if d != 0: ans = (ans + (d*2))%mod ans = (ans + ((d-1) * (b-1))%mod)%mod bb = b // gcd(b, d) ans = (ans + (b-1) // bb)%mod print(ans) if __name__ == '__main__': main()