Hdu 4803 Greed/thinking problem

Source: Internet
Author: User

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; }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.