测试点1——不能单人单间
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n0=0,n1=0,n=0;
cin>>n0>>n1>>n;
int cha=99999999;
int room0=0,room1=0;//女寝和男寝数量
int num0=0,num1=0;//女生和男生每间人数
for(int i=1;i<n;i++)
{
if(n0%i!=0||n1%(n-i)!=0)//排除不能整除的情况
{
continue;
}
// cout<<i;
num0=n0/i;
num1=n1/(n-i);
if(num0==1||num1==1)//不允许一人一间
{
continue;
}
if(abs(num1-num0)<cha)
{
cha=abs(num1-num0);
room0=i;
room1=n-i;
}
}
if(room0!=0&&room1!=0){
cout<<room0<<" "<<room1;
}
else
{
cout<<"No Solution";
}
}