HDU1058Humble Numbers
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Write a program to find and print the nth element in this sequence
Input
Output
Sample Input
Sample Output
#include<bits/stdc++.h>
using namespace std;
int main() {
int n,m2=,m3=,m5=,m7=,i,temp1,temp2;
int a[];
a[]=;
for(i=; i<=; i++) {
a[i]=min(min(*a[m2],*a[m3]),min(*a[m5],*a[m7]));
if(a[i]==*a[m2]) m2++;
if(a[i]==*a[m3]) m3++;
if(a[i]==*a[m5]) m5++;
if(a[i]==*a[m7]) m7++;
}
while(cin>>n,n) {
if(n%==&&n%!=)
printf("The %dst humble number is %d.\n",n,a[n]);
else if(n%==&&n%!=)
printf("The %dnd humble number is %d.\n",n,a[n]);
else if(n%==&&n%!=)
printf("The %drd humble number is %d.\n",n,a[n]);
else
printf("The %dth humble number is %d.\n",n,a[n]);
}
return ;
}
HDU1058Humble Numbers的更多相关文章
- hdu1058Humble Numbers(动态规划)
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range
在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- [LeetCode] Add Two Numbers II 两个数字相加之二
You are given two linked lists representing two non-negative numbers. The most significant digit com ...
- [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字
Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- [LeetCode] Bitwise AND of Numbers Range 数字范围位相与
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...
- [LeetCode] Valid Phone Numbers 验证电话号码
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...
- [LeetCode] Consecutive Numbers 连续的数字
Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | ...
随机推荐
- Like ruby of SBM Crusher zip to dict
how to use the zip to bulid a dict in python? data = """A dynamic, interpreted, open ...
- C# 添加系统计划任务方案
你可以在Windows 计划任务管理器里面添加计划任务,调试OK后导出XML文件,然后在要部署的计算机上执行CMD导入命令,把计划任务信息配置导入到服务器上的计划任务列表中,命令如下: SCHTASK ...
- linux内核SPI总线驱动分析(二)(转)
简而言之,SPI驱动的编写分为: 1.spi_device就构建并注册 在板文件中添加spi_board_info,并在板文件的init函数中调用spi_register_board_info(s3 ...
- C#的编译
Windows上的编译 1:先将C:\Windows\Microsoft.NET\Framework\v3.5配置到系统环境变量的path里. 2:写C#代码 demo1.txt using Syst ...
- xcode4.5应用程序本地化
我们在开发一款APP的时候,总是会涉及应用程序国际化的事情,用ios里专业术语叫做本地化,其实都是一个意思,简而言之就是不同的系统语言,显示不同的应用名称.字符串名称.图片名称.等等,除了代码,ios ...
- SQL基础学习篇--字符函数
字符函数可与SELECT,UPDATE,DELETE RIGHT()----从右侧开始选择 SELECT RIGHT(列,字符数量) FROM 表 LEFT()----从左侧开始选择 SUBSTR ...
- oracle 各种问题排查
一.ORA-00257 ORA-00257归档日志写满,最简单方法.可以更改归档的大小. 二.job不自动运行解决方法 http://www.cnblogs.com/xbding/p/5861443. ...
- Git 设置别名[alias]
工作中我经常设置一下别名... 别名就在[alias]后面,要删除别名,直接把对应的行删掉即可. 而当前用户的Git配置文件放在用户主目录下的一个隐藏文件.gitconfig中: $ cat .git ...
- http压力测试
一.http_load程序非常小,解压后也不到100Khttp_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载.但是它不同于大多数压力测试工具,它可以以一个单一的进程运行,一般不会把 ...
- squid判断文件是否修改机制分析
前提: 1.我写了一个简单的http服务器,以下简称 httpserver 2.前端使用squid做反向代理,以下简称 squid.squid同时反向代理了2台http服务器,其中一台是httpser ...