結果

問題 No.2244 Integer Complete
ユーザー KudeKude
提出日時 2023-03-10 23:05:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,710 bytes
コンパイル時間 2,660 ms
コンパイル使用メモリ 223,092 KB
最終ジャッジ日時 2025-02-11 09:07:47
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 60
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
template<class T>
vector<T> divisors(T x) {
vector<T> res1, res2;
T d = 1;
for(; d * d < x; d++) {
if (x % d == 0) {
res1.emplace_back(d);
res2.emplace_back(x / d);
}
}
if (d * d == x) res1.emplace_back(d);
res1.insert(res1.end(), res2.rbegin(), res2.rend());
return res1;
}
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
VI a(n), b(m);
rep(i, n) cin >> a[i];
rep(i, m) cin >> b[i];
if (a[0] != 1 || b[0] != 1) {
cout << 1 << '\n';
return 0;
}
int mx = n + m + 1;
vector<char> da(mx + 1), db(mx + 1);
for(int x: a) if (x <= mx) da[x] = 1;
for(int y: b) if (y <= mx) db[y] = 1;
int z = 1;
while(da[z] || db[z]) z++;
for(int xy = z * z;; xy++) {
bool ok = false;
for(int x: divisors(xy)) {
if (da[int(sqrt(x))] && db[int(sqrt(xy / x))]) {
ok = true;
break;
}
}
if (!ok) {
cout << xy << '\n';
return 0;
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0