HDOJ 1248 寒冰王座(找规律)

【思路】:找规律,参考的别人的,自己写的挂了。http://blog.csdn.net/appte/article/details/8227632

【AC代码】:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int T = 0;
    cin >> T;
    while (T--)
    {
        int n = 0, m = 0;
        cin >> n;
        if (n<200)
            m = n%150;
        else if (n >= 200 && n < 300)
            m = n%200;
        else if (n >= 300)
            m = n%50;
        cout << m << endl;
    }
    return 0;
}

【自己写的WA代码】:1300时候就是错的,应该是0,输出50。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int T = 0;
    cin >> T;
    while (T--)
    {
        int n = 0;
        cin >> n;
        int a = n%150, b = n%200, c = n%350;
        if (b >= 150)
            b %= 150;
        if (c >= 300)
            c %= 150;
        else if (c >= 200)
            c %= 200;
        else if (c >= 150)
            c %= 150;
        if (a < b)
        {
            if (a < c)
                cout << a << " ";
            else
                cout << c << " ";
        }
        else
        {
            if (b < c)
                cout << b << " ";
            else
                cout << c << " ";
        }
    }
    return 0;
}

方法就是错的,几乎没法改。。

时间: 2024-08-07 08:18:27

HDOJ 1248 寒冰王座(找规律)的相关文章

hdoj 1248 寒冰王座 【完全背包】

寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13257    Accepted Submission(s): 6774 Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑士

HDU 1248寒冰王座-全然背包或记忆化搜索

寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13001    Accepted Submission(s): 6620 Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,仅仅有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑

HDU 1248寒冰王座-完全背包或记忆化搜索

寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13001    Accepted Submission(s): 6620 Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑士

杭电 1248 寒冰王座(完全背包)

http://acm.hdu.edu.cn/showproblem.php?pid=1248 寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10792    Accepted Submission(s): 5476 Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票

hdu 1248 寒冰王座(暴力)

寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13193    Accepted Submission(s): 6730 Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,仅仅有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑

杭电 HDU 1248 寒冰王座

寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 12453    Accepted Submission(s): 6322 Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑士

HDU 1248 寒冰王座 (水题的N种做法!)(含完全背包)

寒冰王座 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13177    Accepted Submission(s): 6718 Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑士:

HDU 1248 寒冰王座(全然背包:入门题)

http://acm.hdu.edu.cn/showproblem.php?pid=1248 题意: 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,仅仅有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑士:"我要买道具!" 地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个." 死亡骑士:"好的,给我一个血瓶." 说完他掏出那张N元的大钞递给地

杭电 1248 寒冰王座【完全背包】

解题思路:直接套公式就可以做的完全背包. Problem Description 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前. 死亡骑士:"我要买道具!" 地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个." 死亡骑士:"好的,给我一个血瓶." 说完他掏出那张N元的大钞递给地精商人. 地精商人:&