当前位置:网站首页>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;
}
边栏推荐
- Janus实际生产案例
- OpenCV图像处理学习四,像素的读写操作和图像反差函数操作
- mysql -sql编程
- Difference Between Data Mining and Data Warehousing
- 进程管理和任务管理
- QT模态对话框及非模态对话框学习
- 【二叉树-中等】1261. 在受污染的二叉树中查找元素
- In automated testing, test data is separated from scripts and parameterized methods
- Deep Learning (5) CNN Convolutional Neural Network
- 【论文粗读】(NeurIPS 2020) SwAV:对比聚类结果的无监督视觉特征学习
猜你喜欢
随机推荐
SQL注入的order by ,limit与宽字节注入
【每日一题】1413. 逐步求和得到正数的最小值
QT模态对话框及非模态对话框学习
.Net面试经验总结
数据治理(五):元数据管理
2022.8.8考试游记总结
量化交易策略介绍及应用市值中性化选股
谷歌翻译器-谷歌翻译器软件批量自动翻译
JCMsuite—单模光纤传播模式
别再用 offset 和 limit 分页了,性能太差!
Maya制作赛博朋克机器人模型
Data Governance (5): Metadata Management
Pagoda server PHP+mysql web page URL jump problem
what is eabi
MySQL:你做过哪些MySQL的优化?
STM32F103驱动HCSR04超声波测距显示
51单片机驱动HMI串口屏,串口屏的下载方式
UXDB现在支持函数索引吗?
The flask to add and delete
【8.8】代码源 - 【不降子数组游戏】【最长上升子序列计数(Bonus)】【子串(数据加强版)】









