BAPC - Choosing Ice Cream

题目来源:https://nanti.jisuanke.com/t/A1729 

BAPC - Choosing Ice Cream_第1张图片

样例输入

3
4 2
2 4
3 2

样例输出

2
1
unbounded

 

题意:我想买冰淇淋但是有选择恐惧症,所以用骰子来决定吃啥味的。但是骰子面数和冰淇淋数不一定相同,所以问我至少要抛多少次才能代表所有冰淇淋种类。

样例解析:4种冰淇淋,一个2面的(骰子)硬币(ˉ▽ ̄~) ,抛两次才有四种可能;两种冰淇淋,一个四面的骰子,可以用两个面对应一种冰淇淋,故只需要抛一次。

思路:设骰子面数M,冰淇淋类T。只有两种可能:M>=T,判断(M%T);M

tips:因为面数不能为1,为1则必定unbounded,又1e9<2的30次方,故i最大为30。 

#include
#include
#include
#define ll long long
using namespace std;
int main()
{
    ll m,t,k;
    cin>>k;
    while(k--)
    {
        cin>>t>>m;
        ll flag=1%t;   //t为1时flag=0
        for(int i=0;i<=30;i++)
        {
            if(!flag)  
            {
                cout<

 

你可能感兴趣的:(赛事回顾)