hdu 3199 丑数2
来源:互联网 发布:网页三剑客过时了 知乎 编辑:程序博客网 时间:2024/06/04 03:46
Hamming Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1124 Accepted Submission(s): 482
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
数据 确实挺吓人的 不确定的时候 用long long 或 __int64
View Code
Problem : 3199 ( Hamming Problem ) Judge Status : Accepted
RunId : 16987110 Language : G++ Author : 1136242673
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
RunId : 16987110 Language : G++ Author : 1136242673
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
#include<stdio.h>#include<string.h>#include<stdlib.h>#define min(a,b)(a<b?a:b)long long a[110000];int p1,p2,p3,n;long long min4(long long a,long long b,long long c){ long long ans1=min(a,b); long long ans=min(ans1,c); return ans;}int main(){ int x1,x2,x3; while(scanf("%d%d%d%d",&p1,&p2,&p3,&n)==4) { a[0]=1; x1=x2=x3=0; for(int i=1;i<=n;i++) { a[i]=min4(a[x1]*p1,a[x2]*p2,a[x3]*p3); if(a[i]==a[x1]*p1) x1++; if(a[i]==a[x2]*p2) x2++; if(a[i]==a[x3]*p3) x3++; } printf("%I64d\n",a[n]); } return 0;}
0 0
- hdu 3199 丑数2
- HDU 3199 Hamming Problem 丑数
- hdu 1058 丑数?
- hdu 1058 Humble Numbers【丑数】
- HDU 丑数 - 1058 Humble Numbers
- 【HDU-1058】Humble Numbers 丑数
- HDU 1058||Uva 136 丑数
- hdu 1058 Humble Numbers 丑数
- Java实现-丑数2
- 丑数
- 丑数
- 丑数
- 丑数
- 丑数
- 丑数
- 丑数
- 丑数
- 丑数
- (2.2.10.3)Gradle 编程模型及 API 实例详解
- C++第四次作业
- Java IO系统——File类
- sql server2008 查询当天,最近三天,本周,本月,最近一个月,本季度的数据的sql语句
- HTML5 data-* 自定义属性
- hdu 3199 丑数2
- java笔记→IO流中字节,字符的输入与输出(文件)
- 主存储器与Cpu的连接
- Synchronized详解
- Java中equals和==的区别
- 浙江省赛zoj3946 Highway Project
- 目录
- MySQL存储引擎--细说MyISAM与InnoDB区别
- C++第4次作业