hdu 3199 Hamming Problem
2015-08-07 22:01
351 查看
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=3199
解题思路:
虽然数很大,但是并没有超过long long 的最大数,所以还是直接按照丑数的求法来就行了。。。
AC代码:
http://acm.hdu.edu.cn/showproblem.php?pid=3199
解题思路:
虽然数很大,但是并没有超过long long 的最大数,所以还是直接按照丑数的求法来就行了。。。
AC代码:
#include <iostream> #include <cstdio> #include <queue> #include <limits> using namespace std; typedef long long ll; typedef pair<ll,int> node_type; ll result; int main(){ //cout<<(numeric_limits<long long>::max)()<<endl; ll p1,p2,p3,n; while(~scanf("%lld%lld%lld%lld",&p1,&p2,&p3,&n)){ priority_queue<node_type,vector<node_type>,greater<node_type> > q; q.push(make_pair(1,p1)); for(int i = 1; i <= n+1; i++){ node_type node = q.top(); q.pop(); if(node.second == p1){ q.push(make_pair(node.first*p1,p1)); q.push(make_pair(node.first*p2,p2)); q.push(make_pair(node.first*p3,p3)); } else if(node.second == p2){ q.push(make_pair(node.first*p2,p2)); q.push(make_pair(node.first*p3,p3)); } else q.push(make_pair(node.first*p3,p3)); result = node.first; } printf("%lld\n",result); } return 0; }
相关文章推荐
- 网易云课堂 浙江大学-陈越、何钦铭-数据结构基础习题集(自测)
- 编程语言
- 网易云课堂 浙江大学-陈越、何钦铭-数据结构基础习题集(自测)
- 充满正能量的关于珍惜时间的名言
- 将数字字符串转换为整型
- C#编程:NetworkStream类的Read
- uva12532 线段树单点更新
- HDU 3081 Marriage Match II(最大流 + 并查集)
- Cocos2d-x学习笔记(四)—— 内存管理
- Lync 2013 语言包安装
- 15年的IT路
- 【js】——如何判断一个字符是否在某个字符数组中
- C++中构造函数和析构函数
- hive 实战笔记case2
- 二叉树的前序,中序,后序遍历
- [算法专题] 深度优先搜索&回溯剪枝
- Mac 安装 Ruby, Rails 运行环境
- 三行css代码实现垂直居中
- FMDB
- Entity Framework教程(第二版)