http://acm.hdu.edu.cn/showproblem.php?pid=4803
Say C + + card accuracy. g++ AC C + + WA
My own greedy strategy is wrong-just try to lower the key, and then the key, the last key to complete, but the sample is not over ...
Reference http://www.cnblogs.com/xuesu/p/3967704.html
Http://www.cnblogs.com/Canon-CSU/p/3451784.html
http://blog.csdn.net/keshuai19940722/article/details/26005267
I don't understand, actually. O (╯-╰) o
#pragma COMMENT (linker, "/stack:102400000,102400000") #include <cstdio> #include <cstring> #include < algorithm> #include <string> #include <iostream> #include <iomanip> #include <cmath> #
Include <map> #include <set> #include <queue> using namespace std; #define LS (RT) rt*2 #define RS (RT) rt*2+1 #define LL long #define ULL unsigned long long #define REP (i,s,e) for (int i =s;i<e;i++) #define REPE (i,s,e) for (int i=s;i<=e;i++) #define CL (A, B) memset (A,b,sizeof (a)) #define in (s) freopen (
S, "R", stdin) #define OUT (s) freopen (S, "w", stdout) const LL ll_inf = ((ull) ( -1)) >>1;
Const double EPS = 1e-8;
Const double PI = ACOs (-1.0);
const int INF = 100000000;
Double p[11];
void Init () {p[0]=0;
for (int i=1;i<=10;i++) p[i]=1+1.0/i; for (int i=0;i<11;i++) cout << "i=" << I << "" << P[i] << End
L } Const Double EPS = 1e-9;///int main () {
In ("Hdu4803.txt");
int x, y;
Init ();
while (~SCANF ("%d%d", &x,&y)) {if (x>y) {puts ("-1"); continue;}
Double k= (1.0*y+1-eps)/x;
int cnt=x-1;
Double Ty=1;
for (int i=1;i<=x;i++) {double t=i*k;
int down= (int) (t-ty);
Ty+=down;
Cnt+=down;
ty=ty* (i+1)/I;
} printf ("%d\n", CNT);
} return 0; }