水题,不过我题目意思没看懂= =,我以为每瓶药水只能用一次,这样的话,第二组样例硬是看不懂= =
最后没做出来
题目解法:1)如果n=1,那么就不需要用兔子来测试,输出0;2)然后在n瓶药水中,把长生不老药减去,如果此时n小于k,说明无法判别出;否则:n能整除k,则结果即为n/k
否则n/k + 1
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n,m;
while (~scanf("%d%d",&n,&m))
{
if (n == 1)
printf("0\n");
else
{
n = n - 1;
if (n < m)
printf("-1\n");
else
{
if (n % m == 0)
printf("%d\n",n/m);
else
printf("%d\n",n/m + 1);
}
}
}
return 0;
}
424

被折叠的 条评论
为什么被折叠?



