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++) { ) ...
随机推荐
- Python下Mysql数据连接池——单例
# coding:utf-8 import threading import pymysql from DBUtils.PooledDB import PooledDB from app.common ...
- ajax数据获取与传送
function service_ajax(){ var migrate_style = $('#myTab').find('.active').attr('value'); //jquery获取页面 ...
- 很有用的PHP笔试题系列一
1.抓取远程图片到本地,你会用什么函数? fsockopen, A 3.用PHP打印出前一天的时间,打印格式是2007年5月10日22:21:21 Echo date(‘Y-m-d H:i:s’,st ...
- 服务器word权限添加
我们的程序部署到IIS上会出现上图所示的错误. 这个是由于IIS没有权限访问word所致. 解决的方法: 在运行对话框中输入: mmc -32 出来如下图的界面: 然后点击"文件&q ...
- JSP初学者4
Filter可认为是Servlet的“加强版”,他主要用于对用户请求进行预处理,也可以对HttpServletResponse进行后处理,是个典型的 处理链. 使用Filter完整的流程是:Filte ...
- 一.配置简单的嵌入式tomcat和jetty
我们写了一个web应用,打成war包后,就需要找一个server来部署.对于我们的实际应用,我们基本没必要自己再写一个嵌入式的server.接下来两篇文章只是以钻研的心态来学习一下嵌入式tomcat和 ...
- 再学UML-Bug管理系统UML2.0建模实例(四)
3.3 顺序图(实现模型) 在系统设计与实现阶段我们也可以使用顺序图进行建模,此时通过顺序图可以明确表示系统设计中对象之间的交互,考虑到具体系统实现,对象之间通过方法调用传递消息.在BMS系统中,对每 ...
- VSCode-python 进阶配置
VSCode-python 进阶配置 中文乱码 中文乱码,网上一堆解决方法,但是根本没有有效起作用的. 在python脚本的前面添加: # -*- coding:utf-8 -*- 并不能在控制台输出 ...
- Linux --防火墙(一)
基本组成 表: filter:用来对数据包进行过滤,根据具体的规则要求决定如何处理一个数据包.表内包含三个链,即INOUT.FORWARD.OUTPUT nat表:主要用来修改数据包的IP地址.端口号 ...
- Linux下实现免密码登录
1.Linux下生成密钥 ssh-keygen的命令手册,通过”man ssh-keygen“命令: 通过命令”ssh-keygen -t rsa“ 生成之后会在用户的根目录生成一个 “.ssh”的文 ...