HDU 1399 Starship Hakodate-maru(暴力搜索)
传送门:
http://acm.hdu.edu.cn/showproblem.php?pid=1399
Starship Hakodate-maru
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 871 Accepted Submission(s): 587
There, however, is an inconvenience. The shapes of the fuel containers #1 and #2 are always cubic and regular tetrahedral respectively. Both of the fuel containers should be either empty or filled according to their shapes. Otherwise, the fuel balls become extremely unstable and may explode in the fuel containers. Thus, the number of fuel balls for the container #1 should be a cubic number (n^3 for some n = 0, 1, 2, 3, ...) and that for the container #2 should be a tetrahedral number (n(n+1)(n+2)/6 for some n = 0, 1, 2, 3, ...).
Hakodate-maru is now at the star base Goryokaku preparing for the next mission to create a precise and detailed chart of stars and interstellar matters. Both of the fuel containers are now empty. Commander Parus of Goryokaku will soon send a message to Captain Future of Hakodate-maru on how many fuel balls Goryokaku can supply. Captain Future should quickly answer to Commander Parus on how many fuel balls she requests before her ship leaves Goryokaku. Of course, Captain Future and her officers want as many fuel balls as possible.
For example, consider the case Commander Parus offers 151200 fuel balls. If only the fuel container #1 were available (i.e. if the fuel container #2 were unavailable), at most 148877 fuel balls could be put into the fuel container since 148877 = 53 * 53 * 53 < 151200 < 54 * 54 * 54. If only the fuel container #2 were available, at most 147440 fuel balls could be put into the fuel container since 147440 = 95 * 96 * 97 / 6 < 151200 < 96 * 97 * 98 / 6. Using both of the fuel containers #1 and #2, 151200 fuel balls can be put into the fuel containers since 151200 = 39 * 39 * 39 + 81 * 82 * 83 / 6. In this case, Captain Future's answer should be "151200".
Commander Parus's offer cannot be greater than 151200 because of the capacity of the fuel storages of Goryokaku. Captain Future and her officers know that well.
You are a fuel engineer assigned to Hakodate-maru. Your duty today is to help Captain Future with calculating the number of fuel balls she should request.
64
50
20
151200
0
64
47
20
151200
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<memory.h>
using namespace std;
int main()
{
int n,i,j,x;
int ans;
while(~scanf("%d",&n))
{
if(n==)
break;
ans=;
for(i=;i*i*i<=n;i++)
{
for(j=;j*(j+)*(j+)/<=n;j++)
{
x=i*i*i+j*(j+)*(j+)/;
if(x<=n)
{
ans=max(ans,x);
}
else
{
break;
}
}
}
printf("%d\n",ans);
}
return ;
}
HDU 1399 Starship Hakodate-maru(暴力搜索)的更多相关文章
- hdu 1399 Starship Hakodate-maru (暴力搜索)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1399 题目大意:找到满足i*i*i+j*(j+1)*(j+2)/6形式且小于等于n的最大值. #inc ...
- HDU 2616 Kill the monster (暴力搜索 || 终极全阵列暴力)
主题链接:HDU 2616 Kill the monster 意甲冠军:有N技能比赛HP有M怪物,技能(A,M),能伤害为A.当怪兽HP<=M时伤害为2*A. 求打死怪兽(HP<=0)用的 ...
- hdu 4740 The Donkey of Gui Zhou(暴力搜索)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4740 [题意]: 森林里有一只驴和一只老虎,驴和老虎互相从来都没有见过,各自自己走过的地方不能走第二次 ...
- HDU 3131 One…Two…Five! (暴力搜索)
题目链接:pid=3131">HDU 3131 One-Two-Five! (暴力搜索) 题意:给出一串数字,要求用加,减,乘,除(5/2=2)连接(计算无优先级:5+3*6=8*6= ...
- hdu 1427 速算24点 dfs暴力搜索
速算24点 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem De ...
- ACM 暴力搜索题 题目整理
UVa 129 Krypton Factor 注意输出格式,比较坑爹. 每次要进行处理去掉容易的串,统计困难串的个数. #include<iostream> #include<vec ...
- HDU 1312 Red and Black --- 入门搜索 BFS解法
HDU 1312 题目大意: 一个地图里面有三种元素,分别为"@",".","#",其中@为人的起始位置,"#"可以想象 ...
- HDU 1312 Red and Black --- 入门搜索 DFS解法
HDU 1312 题目大意: 一个地图里面有三种元素,分别为"@",".","#",其中@为人的起始位置,"#"可以想象 ...
- 随手练——洛谷-P1151(枚举与暴力搜索)
枚举 #include <iostream> using namespace std; int main() { ; cin >> k; ; i < ; i++) { ) ...
随机推荐
- 【ExtJS】关于alias和xtype
alias 在api里的解释为:别名 类名称简短的别名列表.多数用于定义xtypes Ext.define('MyApp.Panel', { extend: 'Ext.panel.Panel', al ...
- 【mysql】mysql数据库安装
今天一直在测功能,整理用例,所以没有去调项目,想到之前有小伙伴求助数据库安装,还远程了一番,所以,就整理一下,数据库在测试工作中还是挺重要的,不能本地测试改个数据都去找开发小哥哥吧,是不是不太好呢,妹 ...
- HDU 1166——敌兵布阵——————【线段树单点增减、区间求和】
敌兵布阵 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- 7、侧边栏:Menu
1.单个侧边栏 导航的代码在分析源码的时候已经分析过了,下面只看他的一些应用与方法. /* ---示例代码----*/ <ion-menu [content]="mycontent&q ...
- Windows phone 8.1应用集成cortana语音命令
微软推出小娜已经有一段时间了,最近恰好在研究其用法,就随便写点记录一下自己的心得. 在研究时参考了@王博_Nick的博客:http://www.cnblogs.com/sonic1abc/p/3868 ...
- ASP .NET SVN && emmet 插件
学习 ASP .NET 时间的第三周: 来讲讲如何在 visual studio 2013...上搭载 SVN吧: 废话不多说: One Step: 电脑上已安装 visual studio 201 ...
- node.js之forEach
forEach用法: var array1=[1,2,3]; array1.forEach(function(item,index){ console.log(item+'---'+index); } ...
- 从零开始的全栈工程师——jQuery
jQueryjq是js一个高效且精简的库( 用的多写得少 ) ,是chrome出版的.jq内部有一个$的方法,他是jq的起始符或标识符,这个方法是用于获取元素. 下载库或者框架的方法官网 produc ...
- SQL Server 2008 R2如何开启数据库的远程连接(转)
SQL Server 2008默认是不允许远程连接的,如果想要在本地用SSMS连接远程服务器上的SQL Server 2008,远程连接数据库.需要做两个部分的配置: SQL Server Manag ...
- js贪食蛇
<!DOCTYPE html><head><title>canvas贪食蛇</title><style>.canvas{ backgr ...