774G - Perfectionist Arkadiy - CodeForces Solution


*special problem number theory *2700

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#include<array>
//#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 200005;
const int mod = 998244353;
typedef pair<int, int> pii;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
const double eps = 1e-6;
int main() {
	int a, h, w;
	cin >> a >> h >> w;
	if (a > h || a > w) {
		cout << -1 << endl;
		return 0;
	}
	double g = gcd(a + h, w + a);
	double y = floor(g * 1.0 / a);
	if ( abs(y) <= eps) {
		cout << -1 << endl;
	}
	else {
		double x = g / y - a;
		printf("%.6llf\n", x);
	}
	return 0;
}


Comments

Submit
0 Comments
More Questions

429A - Xor-tree
1675C - Detective Task
950A - Left-handers Right-handers and Ambidexters
672B - Different is Good
1C - Ancient Berland Circus
721A - One-dimensional Japanese Crossword
1715B - Beautiful Array
60B - Serial Time
453A - Little Pony and Expected Maximum
1715A - Crossmarket
1715C - Monoblock
1512C - A-B Palindrome
1679B - Stone Age Problem
402A - Nuts
792A - New Bus Route
221A - Little Elephant and Function
492C - Vanya and Exams
1369B - AccurateLee
892B - Wrath
999A - Mishka and Contest
727C - Guess the Array
1625C - Road Optimization
1715D - 2+ doors
267A - Subtractions
1582A - Luntik and Concerts
560A - Currency System in Geraldion
946A - Partition
1068B - LCM
1692E - Binary Deque
679A - Bear and Prime 100