Submission #6420942
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll op(ll n) { ll k = n/2; if(n%2) { return k*(k+1); } else { return k*k; } } ll get(ll val) { ll s = 0, e = 3e9; ll ls = 0; while(s <= e) { ll m = (s+e)/2; if(op(m) >= val) { e = m-1; } else { ls = m; s = m+1; } } return ls; } int main() { ll q; scanf("%lld",&q); while(q--) { ll a,b; scanf("%lld %lld",&a,&b); ll tot = a*b; ll res = get(tot)-2; if(a == b) {res = 2*a-2;} printf("%lld\n",res); } }
Submission Info
Submission Time | |
---|---|
Task | D - Worst Case |
User | wwdd |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 547 Byte |
Status | AC |
Exec Time | 3 ms |
Memory | 384 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:28:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld",&q); ^ ./Main.cpp:31:27: 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 | 3 ms | 384 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 |