当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
Pagoda server PHP+mysql web page URL jump problem
2022强网杯 Quals Reverse 部分writeup
JCMsuite—单模光纤传播模式
2022.8.9考试游记总结
xss的DOMPurify过滤框架:一个循环问题以及两个循环问题
.Net interview experience summary
小程序开发的报价为什么有差别?需要多少钱?
sqlmap dolog外带数据
Golang nil的妙用
web crawler error
storage of data in memory
【Kali安全渗透测试实践教程】第6章 密码攻击
【二叉树-中等】1379. 找出克隆二叉树中的相同节点
HRnet
C# 单例模式
mysql -sql编程
2022.8.8考试从记忆中写入(memory)题解
what is a microcontroller or mcu
Algorithm and voice dialogue direction interview question bank
【机器学习】随机森林、AdaBoost、GBDT、XGBoost从零开始理解