結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
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 AC 2 ms
4,348 KB
testcase_17 AC 18 ms
4,432 KB
testcase_18 AC 18 ms
4,432 KB
testcase_19 AC 25 ms
4,432 KB
testcase_20 AC 69 ms
4,348 KB
testcase_21 AC 70 ms
4,348 KB
testcase_22 AC 35 ms
4,348 KB
testcase_23 AC 9 ms
4,348 KB
testcase_24 AC 60 ms
4,348 KB
testcase_25 WA -
testcase_26 AC 13 ms
4,348 KB
testcase_27 AC 78 ms
4,432 KB
testcase_28 AC 29 ms
4,432 KB
testcase_29 AC 77 ms
4,432 KB
testcase_30 AC 64 ms
4,432 KB
testcase_31 AC 10 ms
4,348 KB
testcase_32 AC 9 ms
4,348 KB
testcase_33 AC 4 ms
4,348 KB
testcase_34 WA -
testcase_35 AC 14 ms
4,348 KB
testcase_36 WA -
testcase_37 AC 27 ms
4,348 KB
testcase_38 AC 16 ms
4,348 KB
testcase_39 AC 12 ms
4,348 KB
testcase_40 AC 11 ms
4,348 KB
testcase_41 AC 14 ms
4,348 KB
testcase_42 AC 13 ms
4,348 KB
testcase_43 AC 20 ms
4,348 KB
testcase_44 AC 13 ms
4,348 KB
testcase_45 AC 13 ms
4,348 KB
testcase_46 AC 27 ms
4,348 KB
testcase_47 AC 21 ms
4,348 KB
testcase_48 AC 13 ms
4,348 KB
testcase_49 AC 13 ms
4,348 KB
testcase_50 AC 12 ms
4,348 KB
testcase_51 AC 18 ms
4,348 KB
testcase_52 AC 22 ms
4,348 KB
testcase_53 AC 15 ms
4,348 KB
testcase_54 AC 15 ms
4,348 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
				}
			}
			if (!ar) break;
			ar = false;
			for (int y=0; y<m; y++){
				if (b[y]*b[y] <= j && j < (b[y]+1)*(b[y]+1)){
					ar = true;
				}
			}
			if (ar){
				mode = true;
				break;
			}
		}
		if (!mode) break;
		k++;
	}
	cout << k << endl;
}
0