結果

問題 No.1201 お菓子配り-4
ユーザー chocoruskchocorusk
提出日時 2020-08-29 17:40:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 476 ms / 4,000 ms
コード長 1,152 bytes
コンパイル時間 1,377 ms
コンパイル使用メモリ 126,836 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 23:14:17
合計ジャッジ時間 7,724 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
6,816 KB
testcase_01 AC 232 ms
6,940 KB
testcase_02 AC 326 ms
6,944 KB
testcase_03 AC 162 ms
6,940 KB
testcase_04 AC 80 ms
6,940 KB
testcase_05 AC 197 ms
6,940 KB
testcase_06 AC 32 ms
6,940 KB
testcase_07 AC 90 ms
6,944 KB
testcase_08 AC 246 ms
6,944 KB
testcase_09 AC 185 ms
6,944 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 49 ms
6,944 KB
testcase_12 AC 381 ms
6,944 KB
testcase_13 AC 12 ms
6,940 KB
testcase_14 AC 7 ms
6,940 KB
testcase_15 AC 296 ms
6,940 KB
testcase_16 AC 91 ms
6,940 KB
testcase_17 AC 118 ms
6,940 KB
testcase_18 AC 21 ms
6,940 KB
testcase_19 AC 20 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 474 ms
6,940 KB
testcase_31 AC 475 ms
6,940 KB
testcase_32 AC 473 ms
6,940 KB
testcase_33 AC 476 ms
6,940 KB
testcase_34 AC 476 ms
6,944 KB
testcase_35 AC 120 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll gcd(ll a, ll b){
	if(a==0) return b;
	if(b==0) return a;
	if(a<0) a=-a;
	if(b<0) b=-b;
	const int s=__builtin_ctzll(a|b);
	a>>=__builtin_ctzll(a);
	while(b){
		b>>=__builtin_ctzll(b);
		if(a>b) swap(a, b);
		b-=a;
	}
	return a<<s;
}
int main()
{
	int n, m; cin>>n>>m;
	ll a[2020], b[2020];
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<m; i++) cin>>b[i];
	const ll MOD=1e9+7;
	ll ans=0;
	for(int i=0; i<n; i++){
		if(a[i]==0) continue;
		for(int j=0; j<m; j++){
			ans+=(a[i]-1)*(b[j]-1)+gcd(a[i], b[j])-1+2*a[i];
			ans%=MOD;
		}
	}
	cout<<ans<<endl;
	return 0;
}
0