結果

問題 No.1201 お菓子配り-4
ユーザー chocoruskchocorusk
提出日時 2020-08-29 17:51:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 425 ms / 4,000 ms
コード長 1,154 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 127,604 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 23:35:46
合計ジャッジ時間 6,892 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
6,812 KB
testcase_01 AC 198 ms
6,940 KB
testcase_02 AC 289 ms
6,944 KB
testcase_03 AC 141 ms
6,940 KB
testcase_04 AC 70 ms
6,944 KB
testcase_05 AC 173 ms
6,944 KB
testcase_06 AC 28 ms
6,944 KB
testcase_07 AC 78 ms
6,940 KB
testcase_08 AC 215 ms
6,944 KB
testcase_09 AC 164 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 43 ms
6,940 KB
testcase_12 AC 329 ms
6,940 KB
testcase_13 AC 10 ms
6,944 KB
testcase_14 AC 7 ms
6,944 KB
testcase_15 AC 257 ms
6,940 KB
testcase_16 AC 80 ms
6,940 KB
testcase_17 AC 103 ms
6,944 KB
testcase_18 AC 19 ms
6,944 KB
testcase_19 AC 18 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 412 ms
6,940 KB
testcase_31 AC 425 ms
6,940 KB
testcase_32 AC 424 ms
6,940 KB
testcase_33 AC 413 ms
6,944 KB
testcase_34 AC 420 ms
6,940 KB
testcase_35 AC 135 ms
6,940 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;
int gcd(int a, int 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_ctz(a|b);
	a>>=__builtin_ctz(a);
	while(b){
		b>>=__builtin_ctz(b);
		if(a>b) swap(a, b);
		b-=a;
	}
	return a<<s;
}
int main()
{
	int n, m; cin>>n>>m;
	int 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+=(ll)(a[i]-1)*(b[j]-1)+gcd(a[i], b[j])-1+2*a[i];
			ans%=MOD;
		}
	}
	cout<<ans<<endl;
	return 0;
}
0