結果

問題 No.2244 Integer Complete
ユーザー shobonvipshobonvip
提出日時 2023-03-08 05:34:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,424 bytes
コンパイル時間 4,430 ms
コンパイル使用メモリ 266,752 KB
実行使用メモリ 4,432 KB
最終ジャッジ日時 2023-10-18 05:49:10
合計ジャッジ時間 7,061 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 18 ms
4,432 KB
testcase_18 AC 18 ms
4,432 KB
testcase_19 AC 23 ms
4,432 KB
testcase_20 AC 57 ms
4,348 KB
testcase_21 AC 59 ms
4,348 KB
testcase_22 AC 31 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 51 ms
4,348 KB
testcase_25 AC 41 ms
4,348 KB
testcase_26 AC 13 ms
4,348 KB
testcase_27 AC 62 ms
4,432 KB
testcase_28 AC 27 ms
4,432 KB
testcase_29 AC 61 ms
4,432 KB
testcase_30 AC 53 ms
4,432 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 3 ms
4,348 KB
testcase_34 AC 15 ms
4,348 KB
testcase_35 AC 14 ms
4,348 KB
testcase_36 AC 15 ms
4,348 KB
testcase_37 AC 24 ms
4,348 KB
testcase_38 AC 15 ms
4,348 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 14 ms
4,348 KB
testcase_42 AC 13 ms
4,348 KB
testcase_43 AC 18 ms
4,348 KB
testcase_44 AC 13 ms
4,348 KB
testcase_45 AC 13 ms
4,348 KB
testcase_46 AC 22 ms
4,348 KB
testcase_47 AC 18 ms
4,348 KB
testcase_48 AC 12 ms
4,348 KB
testcase_49 AC 12 ms
4,348 KB
testcase_50 AC 12 ms
4,348 KB
testcase_51 WA -
testcase_52 AC 19 ms
4,348 KB
testcase_53 AC 15 ms
4,348 KB
testcase_54 AC 15 ms
4,348 KB
testcase_55 AC 7 ms
4,348 KB
testcase_56 WA -
testcase_57 AC 3 ms
4,348 KB
testcase_58 AC 13 ms
4,348 KB
testcase_59 AC 13 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

// makediv
vector<ll> makediv(ll n){
	vector<ll> ld, ud;
	for (ll i=1; i*i<=n; i++){
		if (n%i == 0){
			ld.push_back(i);
			if (i != n/i){
				ud.push_back(n/i);
			}
		}
	}
	reverse(ud.begin(), ud.end());
	ld.insert(ld.end(), ud.begin(), ud.end());
	return ld;
}
// -----

int main(){
	int n,m; cin >> n >> m;
	vector<ll> a(n);
	vector<ll> a2(n);
	vector<ll> b(m);
	vector<ll> b2(m);
	for (int i=0; i<n; i++){
		cin >> a[i];
		a2[i] = a[i] * a[i];
	}
	for (int i=0; i<m; i++){
		cin >> b[i];
		b2[i] = b[i] * b[i];
	}

	if (a[0] != 1 || b[0] != 1){
		cout << 1 << endl;
		return 0;
	}

	vector<bool> c(40000);
	for (int i=0; i<n; i++){
		c[a[i]] = true;
	}
	for (int i=0; i<m; i++){
		c[b[i]] = true;
	}

	ll v = 0;
	for (int i=1; i<40000; i++){
		if (!c[i]){
			v = i * i;
			break;
		}
	}

	ll k = v;
	while (true){
		bool mode = false;
		for (ll i: makediv(k)){
			ll j = k / i;
			bool ar = false;
			for (int x=0; x<n; x++){
				if (a[x]*a[x] <= i && i <= (a[x]+1)*(a[x]+1)){
					ar = true;
					break;
				}
			}
			if (!ar) continue;
			ar = false;
			for (int y=0; y<m; y++){
				if (b[y]*b[y] <= j && j <= (b[y]+1)*(b[y]+1)){
					ar = true;
					break;
				}
			}
			if (ar){
				mode = true;
				break;
			}
		}
		if (!mode) break;
		k++;
	}
	cout << k << endl;
}
0