Created
August 28, 2021 05:15
-
-
Save yeopgi/269f9db867acc2d56346f5fad957e1c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| #include<cstdio> | |
| using namespace std; | |
| int warp(int dist) { | |
| long long n, minN, powN, maxN, warpCount= 0; | |
| for(n=1;;n++){ | |
| powN = n*n; | |
| minN = powN - n + 1; | |
| maxN = powN + 1 + n - 1; | |
| if(minN<=dist && dist<=maxN){ | |
| if(minN<=dist && dist<=powN) warpCount = (n<<1) - 1; | |
| else warpCount = n<<1; | |
| break; | |
| } | |
| } | |
| return warpCount; | |
| } | |
| int main() { | |
| int t, x, y, dist; scanf("%d", &t); | |
| while (t--) { | |
| scanf("%d%d", &x, &y); | |
| dist = y - x; | |
| printf("%d\n", warp(dist)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment