ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1854. Negotiations with Parthians

I have WA 36
Posted by arrammis 22 Jan 2015 17:53
My solution pass's all tests presented here in the forum.

<code>
#include <iostream>
using namespace std;

int main()
{
__int64 n, i, a, b, c, maxC1 = 1, maxC2 = 1, maxC = 1;
cin >> n;
for (i = 1; i*i < 1000000; i += 2)
{
if (n % i == 0)
{
a = n/i;
b = sqrtl((long double)a);
c = sqrtl((long double)i);

if (b*b == a && a > maxC1) {
maxC1 = a;
}

if (c*c == i && i > maxC2) {
maxC2 = i;
}

maxC = max(maxC1, maxC2);
}
}

cout << maxC;
return 0;
}
</code>
Do I need to write own sqrt ? What the problem is ?

Edited by author 22.01.2015 17:54
Re: I have WA 36
Posted by Kyle 30 Jan 2018 05:02
For test 36, make sure to use unsigned long longs to prevent overflow:
999999998000000001
999999998000000001