首页 > ACM题库 > HDU-杭电 > hdu 2301 Funny Games待解决[解题报告]C++
2014
01-05

hdu 2301 Funny Games待解决[解题报告]C++

Funny Games

问题描述 :

Nils and Mikael are intergalaxial fighters. Now they are competing for the planet Tellus. The size of this small and unimportant planet is 1 < X < 10000 gobs. The problem is that their pockets only have room for one gob, so they have to reduce the size of the planet. They have available 1 <= K <= 6 FACTOR-weapons characterized by numbers F1, F2, . . . , Fk, all less than 0.9. As is commonly known, a FACTOR-weapon will blow off part of the planet, thus reducing the planet to a fraction of its size, given by the characteristic. Thus, with e.g. F1 = 0.5 an application of the first weapon will half the size of the planet. The fighter who reduces the size to less than, or equal to, 1 gob can take the planet home with him. They take turns attacking the planet with any weapon. If Nils starts, who will win the planet? Assume that both Nils and Mikael are omniscient and always make a winning move if there is one.
Technical note: To ease the problem of rounding errors, there will be no edge cases where an infinitesimal perturbation of the input values would cause a different answer.

输入:

The first line of input is N <= 100, the number of test cases. Each of the next N lines consists of X, K and then the K numbers F1, F2, . . . , Fk, having no more than 6 decimals

输出:

The first line of input is N <= 100, the number of test cases. Each of the next N lines consists of X, K and then the K numbers F1, F2, . . . , Fk, having no more than 6 decimals

样例输入:

4
6 2 0.25 0.5
10 2 0.25 0.5
29.29 4 0.3 0.7 0.43 0.54
29.30 4 0.3 0.7 0.43 0.54

样例输出:

Mikael
Nils
Nils
Mikael


  1. 从我的经历来看,同桌最开始都是门口站两排,一男一女的按高低进去,后来依照学习成绩,老师把成绩好的弄到黑板下吃灰,不好的最后两排睡觉,不过一般都还是一般遵守先男女后同性的原则。。。。。。。。。。所以异性的概率大些

  2. 再也没有人比我更惨了。记得昨天去浴室洗澡洗完准备出去穿衣服的时候。看到有一个3岁左右大的小屁孩挡在门中间,小屁孩旁边有个妇女好像是她妈妈。那个女的看了要出门的我一眼,然后对着小屁孩说:“宝宝乖,快给阿姨让一下”话落,小屁孩让开时还用一种奇特的眼神看着我。

  3. 第二块代码if(it != mp.end())应改为if(it != mp.end() && (i+1)!=(it->second +1));因为第二种解法如果数组有重复元素 就不正确

  4. #include <cstdio>

    int main() {
    //answer must be odd
    int n, u, d;
    while(scanf("%d%d%d",&n,&u,&d)==3 && n>0) {
    if(n<=u) { puts("1"); continue; }
    n-=u; u-=d; n+=u-1; n/=u;
    n<<=1, ++n;
    printf("%dn",n);
    }
    return 0;
    }