結果

問題 No.1201 お菓子配り-4
ユーザー erbowlerbowl
提出日時 2021-02-13 16:04:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 457 ms / 4,000 ms
コード長 616 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 201,116 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 00:32:30
合計ジャッジ時間 8,957 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
4,380 KB
testcase_01 AC 221 ms
4,380 KB
testcase_02 AC 317 ms
4,380 KB
testcase_03 AC 156 ms
4,380 KB
testcase_04 AC 77 ms
4,376 KB
testcase_05 AC 188 ms
4,376 KB
testcase_06 AC 30 ms
4,376 KB
testcase_07 AC 86 ms
4,376 KB
testcase_08 AC 236 ms
4,376 KB
testcase_09 AC 174 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 46 ms
4,376 KB
testcase_12 AC 360 ms
4,380 KB
testcase_13 AC 12 ms
4,376 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 283 ms
4,376 KB
testcase_16 AC 88 ms
4,380 KB
testcase_17 AC 114 ms
4,380 KB
testcase_18 AC 20 ms
4,376 KB
testcase_19 AC 19 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 455 ms
4,376 KB
testcase_31 AC 456 ms
4,380 KB
testcase_32 AC 455 ms
4,376 KB
testcase_33 AC 457 ms
4,376 KB
testcase_34 AC 456 ms
4,376 KB
testcase_35 AC 155 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;

int main() {
    ll n,m;
    std::cin >> n>>m;
        const ll MOD = 1e9+7;

    vector<ll> a(n),b(m);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    for (int i = 0; i < m; i++) {
        std::cin >> b[i];
    }
    ll ans = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            ll g = gcd(a[j],b[i]);
            g%=MOD;
            ans += a[j]%MOD*(b[i]+1)%MOD - (b[i]-g+MOD)%MOD+MOD;
        }
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}
0