93122024-02-20 12:22:57TuruTamasFőzet készítéscpp17Wrong answer 0/5026ms10796 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
ifstream in_file("C:\\verseny\\minta\\be1.txt");
#define input in_file
#define INTHENAMEOFGOD
#else
#define input cin
#define INTHENAMEOFGOD \
    ios::sync_with_stdio(0); \
    cin.tie(0); \
    cout.tie(0);
#endif
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<ll, ll> pii;

ll T, A, B;
set<ll> s;

vector<pii> a, b;

int main() {
    for (ll i = 1; i <= 500; i++) {
        for (ll j = i+1; j <= 500; j++) {
            if (__gcd(i, j) == 1) {
                a.emplace_back(j, i);
                b.emplace_back(i, j);
            }
        }
    }
    
    input >> T;
    for (ll t = 0; t < T; t++) {
        input >> A >> B;
        A--; B--;
        ll c = 1;
        ll aind = 0, bind = 0;
        while (true) {

            if (((a[aind].first <= b[bind].first && a[aind].second <= b[bind].second) || (A >= B)) && (a[aind].first <= A && a[aind].second <= B)) {
                c++;
                A -= a[aind].first;
                B -= a[aind].second;
                aind++;
            } else if (((b[bind].first <= a[aind].first && b[bind].second <= a[aind].second) || (B > A)) && (b[bind].first <= A && b[bind].second <= B)) {
                c++;
                A -= b[bind].first;
                B -= b[bind].second;
                bind++;
            } else {
                break;
            }
        }
        cout << c << "\n";
    }
    cout << endl;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/020ms8180 KiB
2Wrong answer0/025ms8348 KiB
3Wrong answer0/320ms8560 KiB
4Wrong answer0/220ms8836 KiB
5Wrong answer0/321ms8980 KiB
6Wrong answer0/220ms9196 KiB
7Wrong answer0/324ms9344 KiB
8Wrong answer0/224ms9376 KiB
9Wrong answer0/326ms9528 KiB
10Wrong answer0/226ms9556 KiB
11Wrong answer0/225ms9464 KiB
12Wrong answer0/226ms9456 KiB
13Wrong answer0/225ms9596 KiB
14Wrong answer0/226ms9680 KiB
15Wrong answer0/226ms9808 KiB
16Wrong answer0/226ms10168 KiB
17Wrong answer0/226ms10216 KiB
18Wrong answer0/226ms10328 KiB
19Wrong answer0/226ms10412 KiB
20Wrong answer0/324ms10624 KiB
21Wrong answer0/326ms10652 KiB
22Wrong answer0/326ms10672 KiB
23Wrong answer0/326ms10796 KiB