首页 > 其他分享 >HUST 1606 Naive

HUST 1606 Naive

时间:2022-11-09 18:39:20浏览次数:40  
标签:10 No int Naive HUST 1606 flag Yes include


Description



Give you a positive integer x, determine whether it is the sum of three positive cubic numbers.


Input



There’re several test cases. For each case: 
Only one line containing an integer x (  1≤x≤10^6)


Output



For each test case, print “Yes” if it is or “No” if it isn’t. 
(See sample for more details)


Sample Input



1 3 10


Sample Output



No Yes

Yes

判断一个数能不能是三个立方数的和,先预处理一下两个立方数的和,然后询问的时候找一个立方数就好了

#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e6+10;
int x,f[maxn];

int main()
{
for (int i=1;i*i*i<maxn;i++)
{
for (int j=i;j*j*j<maxn;j++)
{
if (i*i*i+j*j*j<maxn) f[i*i*i+j*j*j]=1;
}
}
while (~scanf("%d",&x))
{
int flag=0;
for (int i=1;i*i*i<=x;i++)
{
if (f[x-i*i*i]) {flag=1; break;}
}
printf("%s\n",flag?"Yes":"No");
}
return 0;
}



标签:10,No,int,Naive,HUST,1606,flag,Yes,include
From: https://blog.51cto.com/u_15870896/5837710

相关文章

  • HUST 1602 Substring
    DescriptionThisproblemisquieteasy. Initially,thereisastringA.   Thenwedothefollowingprocessinfinitytimes.  A:=A+......
  • HUST 1599 Multiple
    DescriptionRocket323 lovesmathverymuch.Oneday, Rocket323 gotanumberstring.Hecouldchoosesomeconsecutivedigitsfromthestringtoform......
  • HUST 1600 Lucky Numbers
    DescriptionIsun lovesdigit4and8verymuch.Hethinksanumberisluckyonlyifthenumbersatisfythefollowingconditions: 1.      The......
  • 机器学习 之 朴素贝叶斯(Naive Bayesian Model)文本算法的精确率
    目录​​0、推荐​​​​1、背景​​​​2、效果图​​​​3、本次实验整体流程​​​​4、源代码​​​​6、知识点普及​​​​6.1朴素贝叶斯优点​​​​6.2朴素贝叶斯......
  • 详解线性分类-朴素贝叶斯分类器(Naive Bayes Classifer)【白板推导系列笔记】
    朴素贝叶斯是对数据属性之间的关系进行了假设,即各个属性维度之间独立。 NB中我们假设$X$是离散的,服从多项分布(包括伯努利)。GDA的$X$可以用多维高斯分布表示,但是在NB中我......
  • NaiveBayes-参数求解
    knitr::opts_chunk$set(echo=TRUE)  朴素贝叶斯直观上倒是很容易理解,无非就是求后验概率最大化,但是损失函数、参数求解都是一知半解。本文以离散型朴素贝叶斯为例,做一些......
  • SF1606-ASEMI快恢复二极管SF1606
    编辑:llSF1606-ASEMI快恢复二极管SF1606型号:SF1606品牌:ASEMI封装:TO-220AB特性:快恢复二极管正向电流:16A反向耐压:600V恢复时间:35ns引脚数量:3芯片个数:2芯片尺寸:102M......
  • 【笔记】P1606 [USACO07FEB]Lilypad Pond G 及相关
    题目传送门建图首先,根据题目,可以判断出这是一道最短路计数问题。但是要跑最短路,首先要用他给的信息建图,这是非常关键的一步。根据题意,我们可以想出以下建图规则:起点......
  • vue3 + NaiveUI Modal组件点击右上角x关闭不了弹窗的问题
    不要使用v-modle:show='props.show'的方式。因为使用v-modle后,会警告不能直接修改父组件的值,只是可读的应该采用::show='props.show'@update:show='changeShow'配合@......