Submission #2403323
Source Code Expand
#include<stdio.h> #include<vector> #include<algorithm> #include<string> #include<iostream> #include<set> using namespace std; typedef long long ll; int main() { int query; scanf("%d", &query); for (int p = 0; p < query; p++) { ll a, b; scanf("%lld%lld", &a, &b); if (a > b)swap(a, b); if (a == b || a + 1 == b)printf("%lld\n", a + a - 2); else { ll beg = 0, end = 1010101010LL; for (;;) { if (beg == end)break; ll med = (beg + end + 1) / 2; if (med*med >= a*b)end = med - 1; else beg = med; } if (beg*(beg + 1) < a*b)printf("%lld\n", beg + beg - 1); else printf("%lld\n", beg + beg - 2); } } }
Submission Info
Submission Time | |
---|---|
Task | D - Worst Case |
User | DEGwer |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 680 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:12:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &query); ^ ./Main.cpp:16:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld%lld", &a, &b); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 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 | 1 ms | 256 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 |