HDU3199 Hamming Problem 【数论】
来源:互联网 发布:快速域名网站备案 编辑:程序博客网 时间:2024/05/17 02:49
Hamming Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 703 Accepted Submission(s): 289
Problem Description
For each three prime numbers p1, p2 and p3, let's define Hamming sequence Hi(p1, p2, p3), i=1, ... as containing in increasing order all the natural numbers whose only prime divisors are p1, p2 or p3.
For example, H(2, 3, 5) = 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, ...
So H5(2, 3, 5)=6.
For example, H(2, 3, 5) = 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, ...
So H5(2, 3, 5)=6.
Input
In the single line of input file there are space-separated integers p1 p2 p3 i.
Output
The output file must contain the single integer - Hi(p1, p2, p3). All numbers in input and output are less than 10^18.
Sample Input
7 13 19 100
Sample Output
26590291
Source
Northeastern Europe 2000 - Far-Eastern Subregion
#include <stdio.h>#define maxn 10000__int64 dp[maxn] = {1, 1};__int64 a0, b0, c0, a, b, c;__int64 min(__int64 u, __int64 v, __int64 x){ __int64 tmp = u; if(tmp > v) tmp = v; if(tmp > x) tmp = x; if(tmp == u) ++a; if(tmp == v) ++b; if(tmp == x) ++c; return tmp;}int main(){ __int64 i, n; while(scanf("%I64d%I64d%I64d%I64d", &a0, &b0, &c0, &n) != EOF){ a = b = c = 0; dp[0] = 1; for(i = 1; i <= n; ++i) dp[i] = min(dp[a]*a0, dp[b]*b0, dp[c]*c0); printf("%I64d\n", dp[n]); } return 0;}
0 0
- HDU3199 Hamming Problem 【数论】
- hdu1058 Humble Numbers && hdu3199 Hamming Problem(简单dp)
- POJ 2545 && HDU 3199 Hamming Problem(数论)
- Hamming problem
- Codeforces_356B_Xenia and Hamming(数论)
- POJ 2545 Hamming Problem
- 3199 Hamming Problem
- poj 2545 Hamming Problem
- poj2545 Hamming Problem----暴力
- POJ2545--Hamming Problem
- poj 2545 Hamming Problem
- hdu 3199 Hamming Problem
- HDU 3199Hamming Problem
- hdu 3199 Hamming Problem
- UVA729The Hamming Distance Problem
- TOJ 1753.Hamming Problem
- 729--The Hamming Distance Problem
- JOJ1466:The Hamming Distance Problem
- C++获取文件长度
- 星星流浪的城市
- Node.js 博客实例(五)编辑与删除功能
- 《近匠》RealSense:几行代码,为游戏添增实感交互
- 【转】给定一个函数rand5(),使函数rand7()可以随机等概率的生成1-7的整数
- HDU3199 Hamming Problem 【数论】
- 链表的建立及反转
- 随机化一维数组
- PHP foreach中的引用(&)
- frame,bounds的区别
- 韩国PAYWAVE认证之技术篇
- Java实现深度优先搜索和广度优先搜索
- Android系统开发(8)——linx进程基本概念
- 《精通CSS(第2版)》读书笔记2