2020沈阳icpc I
牛客链接
代码:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;
typedef double dd;
typedef pair<int, int> pii;
typedef pair<dd, dd> pdd;
const int MAXN = 500010;
const int inf = 1e9 + 7;
ll gcd(ll a,ll b)
{
if (b == 0) return a;
return gcd(b, a % b);
}
int main()
{
ll h, m, a;
cin >> h >> m >> a;
if (h * m % 2 == 0 && h * m / 2 == a)
{
printf("%lld", h * m);
return 0;
}
printf("%lld", (2 * (a / gcd(h - 1, h * m)) + 1) * gcd(h - 1, h * m));
}