Pagini recente » Cod sursa (job #256428) | Cod sursa (job #954295) | Cod sursa (job #509696) | Cod sursa (job #1005220) | Cod sursa (job #3305261)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("mins.in");
ofstream fout("mins.out");
map<double,int> M;
void btk(int n,int x,int y,int c,int d)
{
if(n==2 && x!=0 && y!=0)
{
double rap=(double)x/y;
M[rap]++;
return;
}
if(n==0)
{
for(int i=1;i<d;i++)
{
n=1;
x=i;
btk(n,x,y,c,d);
n=0;
x=0;
}
}
else if(n==1)
{
for(int i=1;i<c;i++)
{
n=2;
y=i;
btk(n,x,y,c,d);
n=1;
y=0;
}
}
}
int main()
{
int c,d;
fin>>c>>d;
btk(0,0,0,c,d);
int ans=0;
for(auto it:M)
{
ans++;
//cout<<it.first<<' ';
}
fout<<ans;
return 0;
}