Submission #3225994


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

long long root(long long n){
    long long ret = pow((long double)n, 0.5L);
    while(ret*ret > n) ret--;
    while((ret+1)*(ret+1) <= n) ret++;
    return ret;
}

int main(){
    long long i, j, k;
    int Q;
    cin >> Q;
    for(i=0; i<Q; i++){
        long long A, B;
        cin >> A >> B;
        if(A>B) swap(A, B);
        long long R = root(A*B-1);
        long long ans = A-1 + max(R-A, 0LL) + (A*B-1)/(R+1);
        cout << ans << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task D - Worst Case
User betrue12
Language C++14 (GCC 5.4.1)
Score 700
Code Size 539 Byte
Status AC
Exec Time 11 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 1
AC × 12
Set Name Test Cases
Sample s1.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, s1.txt
Case Name Status Exec Time Memory
01.txt AC 11 ms 640 KB
02.txt AC 1 ms 256 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 1 ms 256 KB
06.txt AC 1 ms 256 KB
07.txt AC 1 ms 256 KB
08.txt AC 1 ms 256 KB
09.txt AC 1 ms 256 KB
10.txt AC 1 ms 256 KB
11.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB