思路
我们需要判断是否存在满足条件的 和 ,使得:
(今天玩的局数不超过 )
是整数(今天赢的局数为整数)
是整数(总赢的局数为整数)
(总局数不少于今天玩的局数)
Broken 的情况
直接排除以下不可能的情况:
-
且 (总胜率为 时,今天不可能有正胜率)。
-
且 (总胜率为 时,今天不可能有非全胜)。
-
最小 (今天玩的局数不可能超过 )。
求最小 的方法 我们需要找到最小的 使得 。
设 。
设 和 。
分解:
其中 ( 和 互质)。
最小 必须满足 。
因为 ,所以 必须是 的倍数。
因此,最小 。
结论
若 且 ,或 且 ,或 ,则输出 Broken。
否则输出 Possible。
Code
#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,t;
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>T;
while(T--)
{
int n,pd,pg;
cin>>n>>pd>>pg;
int d=100/__gcd(pd,100ll);
cout<<"Case #"<<++t<<": ";
if((pg==0&&pd>0)||(pg==100&&pd<100)||(d>n)) cout<<"Broken";
else cout<<"Possible";
cout<<'\n';
}
return 0;
}