从0开始,递增每个人应有的份数,判断整数点,非整数点加1。
// Problem#: 10330
// Submission#: 2718942
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int s=0;
for(int i=1;i<m;i++)
{
double k=n;
double p=m;
if((i*n/m)-(i*k/p)>1e-6 || (i*n/m)-(i*k/p)<-(1e-6) )
{
s+=1;
}
}
cout<<s<<endl;
return 0;
}