当前位置:网站首页>2022.8.9 Exam Cube Sum--1100 Question Solutions
2022.8.9 Exam Cube Sum--1100 Question Solutions
2022-08-10 03:21:00 【bj_hacker】
题目
2、立方和–1100
时间限制: | 空间限制:
题目描述:
给出一个正整数 ,请判断 Can be represented as the sum of cubes of two positive integers.共 组测试数据.
输入格式:
第一行仅有一个正整数 ( ),表示测试数据的组数.
接下来有 组测试数据,There is only one positive integer per line per group ( ).
输出格式:
对于每组测试数据,输出一行一个字符串:
若 Can be represented as the sum of the cubes of two positive integers,输出 ;
否则,输出 ;
输出大小写都行.
思路
用mapTo store cubes,枚举第一个数,在通过mapProve the existence of the second number
重点
注意开longlong
代码实现
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int t;
ll n;
map<ll,bool>mp;
inline void init(){
for(ll i=1;i<=10000;i++)mp[i*i*i]=true;
}
int main(){
scanf("%d",&t);
init();
while(t--){
scanf("%lld",&n);
bool flag=false;
for(ll i=1;i*i*i<=n;i++){
ll s=(ll)n-i*i*i;
if(mp[s]){
flag=true;
break;
}
}
if(flag)printf("YES\n");
else printf("NO\n");
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
QT模态对话框及非模态对话框学习
Golang nil的妙用
剑指offer专项突击版第25天
2022.8.8考试区域链接(district)题解
如何让数据库中的数据同步
【8.8】代码源 - 【不降子数组游戏】【最长上升子序列计数(Bonus)】【子串(数据加强版)】
2022.8.9 Remainder of Exam Balance--1000 Question Solutions
OpenCV图像处理学习一,加载显示修改保存图像相关函数
【Kali安全渗透测试实践教程】第8章 Web渗透
FusionCompute产品介绍
2022.8.9考试游记总结
跨站请求伪造(CSRF)攻击是什么?如何防御?
What is a Cross-Site Request Forgery (CSRF) attack?How to defend?
状态压缩小经验
自动化测试中,测试数据与脚本分离以及参数化方法
openpose脚部标注问题梳理
微透镜阵列的高级模拟
数据治理(五):元数据管理
将信号与不同开始时间对齐
Difference Between Data Mining and Data Warehousing