首页 > 其他 > 详细

HUST 1606 Naive

时间:2016-03-07 09:02:21      阅读:216      评论:0      收藏:0      [点我收藏+]

预处理一下,然后o(1)询问。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<algorithm>
using namespace std;

int x;
int a[200];
map<int, bool>m;

void init()
{
    m.clear(); 
    int tot = 0;
    for (int i = 1; i <= 100; i++) a[tot++] = i*i*i;

    for (int i = 0; i < tot; i++)
    {
        for (int j = 0; j < tot; j++)
        {
            for (int z = 0; z < tot; z++)
            {
                m[a[i] + a[j] + a[z]] = 1;
            }
        }
    }

}

int main()
{
    init(); 
    while (~scanf("%d", &x))
    {
        if (m[x]) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

 

HUST 1606 Naive

原文:http://www.cnblogs.com/zufezzt/p/5249327.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!