Gym

题目链接:http://codeforces.com/gym/100187/problem/A


题解:

光题意就想了很久:在最坏情况下的最小兔子数。其实就是至少用几只兔子就一定能找出仙药(答案存在的话)。再注意一下特殊情况就可以了,


代码如下:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define ms(a, b)  memset((a), (b), sizeof(a))
//#define LOCAL
#define eps 0.0000001
typedef long long LL;
const int inf = 0x3f3f3f3f;
const int maxn = 200000+10;
const int mod = 1000000007;

int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
//      freopen("output.txt", "w", stdout);
    #endif // LOCAL
    int n,k;
    cin>>n>>k;
    if(n==1) puts("0");
    else if(n==k) puts("-1");
    else if(k==1) printf("%d
",n-1);
    else
    {
        if(n%k==0||n%k==1)
            printf("%d
",n/k);
        else
            printf("%d
",n/k+1);
    }
}


原文地址:https://www.cnblogs.com/DOLFAMINGO/p/7538729.html