Files
OI-source/1.2735.cpp
2023-08-03 09:22:52 +08:00

22 lines
370 B
C++

#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,p;
inline int gcd(int a,int b)
{
int t;
while(b) { t=b; b=a%b; a=t; }
return a;
}
int main()
{
#ifdef local
freopen("pro.in","r",stdin);
#endif
scanf("%d%d%d",&n,&m,&p);
double S=m*p*0.5,I=p+gcd(n,m)+gcd(abs(n-p),m);
// printf("S=%lf I=%lf\n",S,I);
printf("%d\n",int(S+1-I*0.5+0.5));
return 0;
}