Test instructions: There are n bottles, there is a poison, and then every time to take the rabbit to try to eat K bottle and can only be K bottle, if the rabbit died know that the bottle is poison, now ask you at least a rabbit to try to eat a few times.
Analysis: This problem card for a long time, in fact very simple. First consider sure to eat n/k times, then the rest if only one bottle or not, then the answer is n/k, if there are more than two bottles, you only need to eat again on the line. Because rabbits only need to eat m-1 bottles in the remaining m bottles, and then in the previous n-m bottle to eat (k-m+1) bottle, you can know that the remaining is poison.
1#include <cstdio>2#include <cmath>3#include <cstring>4#include <ctime>5#include <iostream>6#include <algorithm>7#include <Set>8#include <vector>9#include <sstream>Ten#include <queue> One#include <typeinfo> A#include <fstream> -#include <map> -#include <stack> the using namespacestd; -typedefLong Longll; - intMain () - { + ll N,k; -scanf"%i64d%i64d",&n,&k); +ll ans=n/k,r=n%K; A if(n==k&&n!=1) printf ("-1\n"); at Else{ - if(k==1) printf ("%d\n", N-1); - Else{ - if(r==0|| r==1) printf ("%i64d\n", ans); - Elseprintf"%i64d\n", ans+1); - } in } - return 0; to}
Gym 100187a-potion of Immortality