結果

問題 No.2244 Integer Complete
ユーザー Jeroen Op de BeekJeroen Op de Beek
提出日時 2023-03-10 23:19:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,266 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 203,260 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-18 05:30:53
合計ジャッジ時間 4,797 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;
int main() {
    // ok, what can I not do?
    // some integer such that
    // prime you cannot make at least...
    // 1e4 + something to be prime, it's impossible to make
    // so can just brute force check 1e4 candidates.
    // for each candidate, factorize
    int n,m; cin >> n >> m;
    vi a(n),b(m);
    for(auto& i : a) cin >> i;
    for(auto& i : b) cin >> i;
    // can make a lot more numbers than I thought
    // some prime such that it's not within those and not within those?
    // actually a bit like convolution.
    // but multiplicative.
    // answer not bigger than 1e9+7.
    // if you just constantly do the least thing not being able
    // ok, a prime number has to be made by 1 p, or p 1.
    // so if there's some gap, than immediately smaller than the gap you win
    // everything up to that can be made
    vi cnt(max(*max_element(all(a)), *max_element(all(b))) + 100);
    for(int i : a) cnt[i]++;
    for(int j : b) cnt[j]++;
    int i=1;
    if(cnt[1]==2) {
        while(cnt[i]) ++i;
    }
    // now restrict to here
    // need to test ~1e4 candidates
    for(ll c=i*i;;c++) {
        bool gd=0;
        auto check = [&](ll i, ll j) {
            i = sqrtl(i+0.5L), j =sqrtl(j+0.5L);
            cnt[i]--;
            cnt[j]--;
            if(cnt[i]>=0 and cnt[j]>=0) gd=1;
            cnt[i]++,cnt[j]++;
        };
        for(ll j=1;j*j<=c;++j) {
            if(c%j==0) {
                check(j,c/j);
                check(c/j,j);
            }
        }
        if(!gd) {
            cout << c << '\n';
            break;
        }
    }
}
0