题目链接:

  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829

题目描述:

  Mike is very lucky, as he has two beautiful numbers, 3 and 5. But he is so greedy that he wants infinite beautiful numbers. So he declares that any positive number which is dividable by 3 or 5 is beautiful number. Given you an integer N (1 <= N <= 100000), could you please tell mike the Nth beautiful number?

Input

The input consists of one or more test cases. For each test case, there is a single line containing an integer N.

Output

For each test case in the input, output the result on a line by itself.

Sample Input

1
2
3
4

Sample Output

3
5
6
9

  1. /*问题 查询第几个漂亮数字是多少
  2. 解题思路 一般来讲,最直观的做法是将创建一个10 0000的数组,将每个漂亮数存进数组,最后查询即可*/
  3. #include <cstdio>
  4. int bn[];
  5. int main()
  6. {
  7. int count=,i=;
  8. while()
  9. {
  10. if(i % == || i % == ){
  11. bn[count++]=i;
  12. if(count > )
  13. break;
  14. }
  15. i++;
  16. }
  17. int n;
  18. while(scanf("%d",&n) != EOF)
  19. {
  20. printf("%d\n",bn[n]);
  21. }
  22. return ;
  23. }

zoj Beautiful Number(打表)的更多相关文章

  1. HDU 5179 beautiful number (数位dp / 暴力打表 / dfs)

    beautiful number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. zoj 2829 Beautiful Number

    Beautiful Number Time Limit: 2 Seconds      Memory Limit: 65536 KB Mike is very lucky, as he has two ...

  3. hdu 5179 beautiful number

    beautiful number 问题描述 令 A = \sum_{i=1}^{n}a_i * {10}^{n-i}(1\leq a_i \leq 9)A=∑​i=1​n​​a​i​​∗10​n−i​ ...

  4. Codeforces 55D Beautiful Number

    Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...

  5. beautiful number 数位DP codeforces 55D

    题目链接: http://codeforces.com/problemset/problem/55/D 数位DP 题目描述: 一个数能被它每位上的数字整除(0除外),那么它就是beautiful nu ...

  6. Beautiful Number

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2829 Beautiful Number Time Limit: 2 Sec ...

  7. ZOJ 3622 Magic Number 打表找规律

    A - Magic Number Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Subm ...

  8. Codeforces 55D Beautiful Number (数位统计)

    把数位dp写成记忆化搜索的形式,方法很赞,代码量少了很多. 下面为转载内容:  a positive integer number is beautiful if and only if it is  ...

  9. codeforces 893B Beautiful Divisors 打表

    893B Beautiful Divisors 思路: 打表 代码: #include <bits/stdc++.h> using namespace std; #define _for( ...

随机推荐

  1. SRM480

    250pt: 题意:给定n个网站,以及n个网站的关键词,还有一个危险词库.如果一个网站的关键词中>=th的危险词,那么这个网站便是危险的.同时,他的所有关键词加入危险词库.问,有多少个危险网站. ...

  2. CUDA cufftPlanMany的用法_31通道32*8像素的FFT

    #include <cufft.h> #include <iostream> #include <cuda_runtime.h> #include <help ...

  3. 解决UNIGUI字体太小的问题

    解决UNIGUI字体太小的问题 Unigui运行在chrome浏览器下可以有最佳的效果,但用ie打开用unigui做的项目会发现字体明显小一截,可以用自定义css来解决这个问题. 可以在UniServ ...

  4. 「PKUSC2018」最大前缀和(状压dp)

    前言 考试被\(hyj\)吊着打... Solution 考虑一下如果前缀和如果在某一个位置的后面的任意一个前缀和都<=0,肯定这就是最大的. 然后这样子就考虑左右两边的状压dp,然后就好了. ...

  5. Influxdb简介与安装

    InfluxDB 是用Go语言编写的一个开源分布式时序.事件和指标数据库,无需外部依赖,类似的数据库有Elasticsearch.Graphite等 功能特色 基于时间序列,支持与时间有关的相关函数( ...

  6. underscore.js源码研究(5)

    概述 很早就想研究underscore源码了,虽然underscore.js这个库有些过时了,但是我还是想学习一下库的架构,函数式编程以及常用方法的编写这些方面的内容,又恰好没什么其它要研究的了,所以 ...

  7. 组件基础(非父子组件传值)—Vue学习笔记

    最近几天忙着写Api去了,抽空把后面的内容下出来,然后再分享给大家web可以使用的api. 上次说了父子组件直接的传值,这次看一下非父子组件之间的传值(总线机制) 要实现非父子组件之间的传值非常重要的 ...

  8. WebSocket集成XMPP网页即时通讯1:Java Web Project服务端/客户端Jetty9开发初探

    Web 应用的信息交互过程通常是客户端通过浏览器发出一个请求,服务器端接收和审核完请求后进行处理并返回结果给客户端,然后客户端浏览器将信息呈现出来,这种机制对于信息变化不是特别频繁的应用尚能相安无事, ...

  9. WebDriver高级应用实例(10)

    10.1控制HTML5语言实现的视频播放器 目的:能够获取html5语言实现的视频播放器视频文件的地址.时长.控制进行播放暂停 被测网页的网址: http://www.w3school.com.cn/ ...

  10. 12-02 java String类

    String构造方法 package cn.itcast_01; /* * 字符串:就是由多个字符组成的一串数据.也可以看成是一个字符数组. * 通过查看API,我们可以知道 * A:字符串字面值&q ...