Starship Hakodate-maru

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 751    Accepted Submission(s): 518

Problem Description
The
surveyor starship Hakodate-maru is famous for her two fuel containers
with unbounded capacities. They hold the same type of atomic fuel balls.

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.

 
Input
The
input is a sequence of at most 1024 positive integers. Each line
contains a single integer. The sequence is followed by a zero, which
indicates the end of data and should not be treated as input. You may
assume that none of the input integers is greater than 151200.
 
Output
The
output is composed of lines, each containing a single integer. Each
output integer should be the greatest integer that is the sum of a
nonnegative cubic number and a nonnegative tetrahedral number and that
is not greater than the corresponding input number. No other characters
should appear in the output.
 
Sample Input
100
64
50
20
151200
0
 
Sample Output
99
64
47
20
151200
 
Source
 
Recommend
Ignatius.L   |   We have carefully selected several similar problems for you:  1551 2141 2289 2899 2199
 
题意:大概就是问 a*a*a+b*(b+1)*(b+2)最接近 n 的那个数是多少?
题解:两层for循环扫一遍。。
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <iostream>
#include <map>
using namespace std;
int n;
int main()
{
while(scanf("%d",&n)!=EOF,n){
int ans = ,ans1 = ;
for(int i=;i<=;i++){
if(i*i*i>n) break;
ans = i;
}
for(int i=;i<=;i++){
if(i*(i+)*(i+)>*n) break;
ans1 = i;
}
int res = ;
for(int i=;i<=ans+;i++){
for(int j=;j<=ans1+;j++){
if(i*i*i+j*(j+)*(j+)/>n) {
break;
}
res = max(res,i*i*i+j*(j+)*(j+)/);
}
}
printf("%d\n",res);
}
}

hdu 1399(水题)的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  3. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  4. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  5. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  6. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  7. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  8. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  9. hdu 5038 水题 可是题意坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心  If not all ...

随机推荐

  1. JS 中类型鉴别

    JS中的基本类型有:数字(Number(NaN,Infinity)),字符串(String),Undefined,Null,Boolean 引用类型有:数组(Array),对象(Object),函数( ...

  2. 查看Django版本

    python -m django --version dd

  3. POJ2155 树状数组

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 26650   Accepted: 9825 Descripti ...

  4. 再续前缘-apache.commons.beanutils的补充

    title: 再续前缘-apache.commons.beanutils的补充 toc: true date: 2016-05-32 02:29:32 categories: 实在技巧 tags: 插 ...

  5. Perl6 Bailador框架(8):自定义400/500

    第一种方法, 直接写在源码中: use Bailador; get '/' => sub { '<h1>hello, Bailador</h1>'; } get '/te ...

  6. docker使用小记

    查看当前镜像:docker images 运行一个简单的镜像:docker run hello-world 拉取一个远程docker:docker pull centos docker中安装nginx ...

  7. k8s取节点内docker中的日志

    Kubernetes(k8s)是Google开源的容器集群管理系统(谷歌内部:Borg).在Docker技术的基础上,为容器化的应用提供部署运行.资源调度.服务发现和动态伸缩等一系列完整功能,提高了大 ...

  8. Django 1.10中文文档-第一个应用Part3-视图和模板

    本教程上接Django 1.10中文文档-第一个应用Part2-模型和管理站点.我们将继续开发网页投票这个应用,主要讲如何创建一个对用户开放的界面. 概览 视图是Django应用中的一“类”网页,它通 ...

  9. linux中的tasklet机制【转】

    转自:http://blog.csdn.net/yasin_lee/article/details/12999099 转自: http://www.kerneltravel.net/?p=143 中断 ...

  10. SD卡 模拟SPI总线控制流程

    SD卡为移动设备提供了安全的,大容量存储解决方法.它本身可以通过两种总线模式和MCU进行数据传输,一种是称为SD BUS的4位串行数据模式,另一种就是大家熟知的4线SPI Bus模式.一些廉价,低端的 ...