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. +----+-----+ | ...
随机推荐
- Yii中使用PHPexcel获取excel中数据
1.view中代码如下: <form name="frmBatchSettle" id="" action="" method=&qu ...
- svn的使用!!!
1.SVN:subversion(子级源代码版本控制管理软件) 2.SVN的作用 (1)避免开发同一项目不会出现代码覆盖. (2)同一文件可以创建许多不同的版本,并可以随时查看不同版本的内容. (3) ...
- delphi 2010是动画GIF的支持方法
下面delphi 2010是动画GIF的支持方法: 1.在窗体上放一个Image1控件.注意:这时设置其Picture属性,加载一幅动画GIF是不会动画显示的. 2.在窗体的FormCreate事 ...
- MVC 区分是哪按键提交FORM
原理: 引用model(@model modelName)的画面,提交到后台的model对象,属性与前台post标签name属性对应来获取值. 前台: @model myModel @using(Ht ...
- python datetime date time详解
之前一直被datetime,date,time弄的有点乱,可能是因为看文档每太看明白,找到了两篇文章供大家阅读都是转载的,其中有些名词这里解释一下: 世界协调时间(Universal Time Coo ...
- 在newegg工作的这两个月
6月11号,接到录用通知后的第二天,来到了Newegg . 作为开发,在本职工作上 1.入职Quick Start: 两周多的入职快速指引,以了解业务,架构为目的. 因为之前一直有用思维导图的习惯,所 ...
- Express实现http和https服务
一.介绍Http与Https 概念 HTTP: 超文本传输协议(Hypertext transfer protocol) 是一种详细规定了浏览器和万维网服务器之间互相通信的规则,通过因特网传送万维网文 ...
- android----Java DES加密算法工具类
DESUtil类 public class DESUtil { private static byte[] iv = {0x12, 0x34, 0x56, 0x78, (byte) 0x90, (by ...
- nodejs base64 编码解码
普通字符串 编码解码: var b = new Buffer('JavaScript'); var s = b.toString('base64'); // SmF2YVNjcmlwdA== var ...
- 两个有用的shell工具总结
shell工具之一:sed sed基础 sed编辑器被称作流编辑器,与常见的交互式文本编辑器刚好相反.文本编辑器可以通过键盘来交互式地插入.删除.替换文本中的数据:而流编辑器是基于一组预先的规则来编辑 ...