当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
【二叉树-中等】1261. 在受污染的二叉树中查找元素
ECCV 2022 Oral | CCPL: 一种通用的关联性保留损失函数实现通用风格迁移
Pagoda server PHP+mysql web page URL jump problem
具有多孔光纤的偏振分束器
T5:Text-toText Transfer Transformer
SQLserver adds a judgment
深度学习(五) CNN卷积神经网络
【二叉树-简单】112. 路径总和
xss的DOMPurify过滤框架:一个循环问题以及两个循环问题
浅写一个下拉刷新组件
夏克-哈特曼波前传感器
翻译工具-翻译工具下载批量自动一键翻译免费
2022 Top Net Cup Quals Reverse Partial writeup
宝塔服务器PHP+mysql网页URL跳转问题
2022.8.9考试平衡的余数--1000题解
桌面云组件介绍与安装
UXDB现在支持函数索引吗?
openpose脚部标注问题梳理
Go语言JSON文件的读写操作
通关剑指 Offer——剑指 Offer II 012. 左右两边子数组的和相等









