Submission #1073321

# Submission time Handle Problem Language Result Execution time Memory
1073321 2024-08-24T12:23:12 Z beaconmc Pictionary (COCI18_pictionary) C++17
0 / 140
740 ms 2132 KB
#include <bits/stdc++.h>

typedef long long ll;

#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i++)

using namespace std;


int main(){
    ll n,m,q;
    cin >> n >> m >> q;

    FOR(i,0,q){
        ll ans = m;
        ll a,b;
        cin >> a >> b;
        vector<ll> as, bs;

        FOR(i,1,sqrt(a)+2){
            if (a%i==0){
                as.push_back(i);
                as.push_back(a/i);
            }
        }

        FOR(i,1,sqrt(b)+2){
            if (b%i==0){
                bs.push_back(i);
                bs.push_back(b/i);
            }
        }

        for (auto&A : as){
            for (auto&B : bs){
                if (lcm(A,B) <= n && 0<=m-min(A,B)){
                    ans = min(ans, m-min(A,B));
                }
            }
        }
        cout << ans+1 << "\n";
    }    
}
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 260 ms 1480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 225 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 402 ms 1592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 681 ms 1576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 624 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 740 ms 2132 KB Output isn't correct
2 Halted 0 ms 0 KB -