Created
September 26, 2015 12:50
-
-
Save OmarJH/3d9a581917eb33f2b129 to your computer and use it in GitHub Desktop.
Syrian Collegiate Programming Contest
This file contains 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 <algorithm> | |
#include <cmath> | |
using namespace std; | |
long double sec(long double a, long double b, long double c) | |
{ | |
long double del = b*b - 4 * a *c; | |
long double x1 = (-sqrt(del) - b) / 2*a; | |
long double x2 = (sqrt(del) - b) / 2*a; | |
if (x1 > 0 && x1 < 0) | |
return x1; | |
if (x2>0 && x1 < 0) | |
return x2; | |
return x2; | |
} | |
int main() | |
{ | |
int c = 1; | |
long long m, u, d,t; | |
int n; | |
cin >> t; | |
while (t--) | |
{ | |
cin >> n>> m; | |
m--; | |
long long j =floor (sec(1, 1, -2 * m)); | |
d = m - (j*(j + 1)) / 2; | |
cout << "Case " << c++ << ": "; | |
cout << j << " " << d << endl; | |
} | |
//cin >> t; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://codeforces.com/gym/100500