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. +----+-----+ | ...
随机推荐
- C++实现按绩点排名
题目内容:有一些班级的学生需要按绩点计算并排名.每门课的成绩只有在60分以上(含),才予以计算绩点.课程绩点的计算公式为:(课程成绩-50)÷10×学分数.一个学生的总绩点为其所有课程绩点总和除以10 ...
- 强大的网络通信框架(实现缓存)--第三方开源--volley
Android Volley是Android平台上很好用的第三方开源网络通信框架.使用简答,功能强大. Android Volley的库jar包Volley.ja下载连接地址:Volley下载 下载后 ...
- Delphi 泛型对象类
{ 很早就写了. 只针对delphixe 以上的版本可用. 希望不是自己在造轮子. } 1 unit U_ClassUtility; interface uses generics.defaults, ...
- 关于frameset中指定区域回退的实现
指定区域(Frame)的回退,网上大都写的是用 window.parent.window.mainFrame.rightFrame.history.back();来进行回退,但是我这边就是不行,一直 ...
- 不复杂的Autofac注入
private static void SetAutofacWebAPI() { var builder = new ContainerBuilder(); #region 配置注册方法 string ...
- JLINK V8 Keil MDK4.10 STM32
新买的JLINK v8仿真器,第一次使用,编译环境是Keil MDK4.10,目前芯片是STM32F103x. 按照光盘的说明先安装了驱动,USB接上JLINK v8,显示驱动成功.但是在debug或 ...
- ES5 vs ES6
ES5中 var React = require('react-native'); ES6中 import React from 'react-native'; .babelrc文件中添加一下内容 { ...
- iOS学习之Object-C语言类的扩展
一.Category 1.Category:也叫分类,类目.是为没有源代码的类扩充功能.扩充的功能会成为原有类的一部分,可以通过原有类或者原有的对象直接调用,并且可继承. 2.注意 ...
- iOS学习之Object-C语言字符串和数值
一.使用苹果帮助文档 1.帮助文档的作用:帮助开发者快速了解系统类的功能. 1)苹果每次iOS版本的升级,都会添加或者更新大量的API,并提供相应的参考文档. ...
- [转]Not enough free disk space on disk '/boot'
Not enough free disk space on disk '/boot' http://my.oschina.net/u/947673/blog/277224 # 解决 出现此情况是因为你 ...