93112024-02-20 12:18:21TuruTamasFőzet készítéscpp17Wrong answer 0/5026ms10976 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 >= B && a[aind].first <= A && a[aind].second <= B) {
                c++;
                A -= a[aind].first;
                B -= a[aind].second;
                aind++;
            } else if (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/020ms8172 KiB
2Wrong answer0/024ms8460 KiB
3Wrong answer0/320ms9028 KiB
4Wrong answer0/220ms8832 KiB
5Wrong answer0/320ms9032 KiB
6Wrong answer0/220ms9052 KiB
7Wrong answer0/325ms9284 KiB
8Wrong answer0/226ms9564 KiB
9Wrong answer0/325ms9732 KiB
10Wrong answer0/224ms9828 KiB
11Wrong answer0/226ms9968 KiB
12Wrong answer0/224ms10200 KiB
13Wrong answer0/224ms10308 KiB
14Wrong answer0/226ms10552 KiB
15Wrong answer0/226ms10780 KiB
16Wrong answer0/224ms10876 KiB
17Wrong answer0/226ms10936 KiB
18Wrong answer0/225ms10976 KiB
19Wrong answer0/226ms10868 KiB
20Wrong answer0/326ms10888 KiB
21Wrong answer0/326ms10908 KiB
22Wrong answer0/324ms10920 KiB
23Wrong answer0/326ms10908 KiB