Submission #2868105
Source Code Expand
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int Q = sc.nextInt(); long[] A = new long[Q+1]; long[] B = new long[Q+1]; for(int i=1;i<=Q;i++){ long num1 = sc.nextLong(); long num2 = sc.nextLong(); A[i] = Math.min(num1,num2); B[i] = Math.max(num1,num2); } for(int i=1;i<=Q;i++){ if(A[i]==B[i]){ System.out.println(2*(A[i]-1)); continue; } long ans1 = (A[i]-1)*2; long ans2 = 0; long upper = A[i]*B[i]; if((upper-1)/A[i]>A[i]) ans2++; long left = A[i]+1; long right = upper/left; while(right>left){ ans2 += 2; left += 1; right = A[i]*B[i]/left; } if(left==right&&left*right<upper) ans2++; System.out.println(ans1+ans2); } } }
Submission Info
Submission Time | |
---|---|
Task | D - Worst Case |
User | AlbertZ |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1082 Byte |
Status | WA |
Exec Time | 2109 ms |
Memory | 21972 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||||
Status |
|
|
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 | 110 ms | 19412 KB |
02.txt | AC | 108 ms | 18644 KB |
03.txt | TLE | 2108 ms | 18900 KB |
04.txt | WA | 401 ms | 21460 KB |
05.txt | TLE | 2109 ms | 19668 KB |
06.txt | WA | 117 ms | 21076 KB |
07.txt | TLE | 2108 ms | 21972 KB |
08.txt | TLE | 2108 ms | 20052 KB |
09.txt | TLE | 2108 ms | 18896 KB |
10.txt | TLE | 2108 ms | 20180 KB |
11.txt | WA | 95 ms | 20560 KB |
s1.txt | AC | 338 ms | 21332 KB |