結果

問題 No.1201 お菓子配り-4
ユーザー yudedakoyudedako
提出日時 2020-09-07 13:59:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,339 ms / 4,000 ms
コード長 893 bytes
コンパイル時間 1,350 ms
コンパイル使用メモリ 108,832 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 16:43:48
合計ジャッジ時間 16,875 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
4,380 KB
testcase_01 AC 526 ms
4,380 KB
testcase_02 AC 756 ms
4,380 KB
testcase_03 AC 368 ms
4,384 KB
testcase_04 AC 179 ms
4,380 KB
testcase_05 AC 448 ms
4,384 KB
testcase_06 AC 68 ms
4,380 KB
testcase_07 AC 203 ms
4,384 KB
testcase_08 AC 563 ms
4,384 KB
testcase_09 AC 415 ms
4,380 KB
testcase_10 AC 5 ms
4,384 KB
testcase_11 AC 108 ms
4,380 KB
testcase_12 AC 864 ms
4,384 KB
testcase_13 AC 25 ms
4,384 KB
testcase_14 AC 13 ms
4,384 KB
testcase_15 AC 681 ms
4,384 KB
testcase_16 AC 207 ms
4,384 KB
testcase_17 AC 267 ms
4,380 KB
testcase_18 AC 44 ms
4,380 KB
testcase_19 AC 42 ms
4,384 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 1,094 ms
4,380 KB
testcase_31 AC 1,095 ms
4,380 KB
testcase_32 AC 1,093 ms
4,380 KB
testcase_33 AC 1,093 ms
4,384 KB
testcase_34 AC 1,094 ms
4,380 KB
testcase_35 AC 2,339 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
long long int gcd(const long long int a, const long long int b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int n, m; std::cin >> n >> m;
	std::vector<long long int> a_num(n), b_num(m);
	for (auto& a : a_num) std::cin >> a;
	for (auto& b : b_num) std::cin >> b;
	constexpr long long int MOD = 1000000007;
	long long int result{ 0 };
	for (const auto a : a_num) {
		for (const auto b : b_num) {
			const auto g = gcd(a, b);
			const auto bd = b / g;
			result = (result + ((b + 1) * a % MOD - (bd - 1) * g % MOD)) % MOD;
		}
	}
	std::cout << (result + MOD) % MOD << '\n';
}
0