hdoj 5878 I Count Two Three
来源:互联网 发布:果园拆分系统源码 编辑:程序博客网 时间:2024/05/22 17:28
题目链接:I Count Two Three
题目大意:给你一个n,要求你找出大于等于n的第一个满足可以分解为2^a*3^b*5^c*d^7这种形式的数
题目思路:大家都是四层循环打表的吗?我们队伍的做法是丑数的做法,也是打表,不过好像时间复杂度低一点,而且可以解决不止2,3,5,7四个数的情况,打完表直接二分去找就好了,具体看代码吧
#include<bits/stdc++.h>using namespace std;typedef long long ll;ll a[1000005],b[4] = {2,3,5,7},c[1000005];int main(){ ll n,i,j,mi,t; for(i=0;i<4;i++) c[i]=0; a[0]=1; for(i=1;i<=1000005;i++){ mi=2e9; for(j=0;j<4;j++){ while(a[c[j]]*b[j]<=a[i-1]) c[j]++; mi=min(mi,a[c[j]]*b[j]); } a[i]=mi; } scanf("%lld",&t); while(t--){ scanf("%lld",&n); printf("%lld\n",a[lower_bound(a,a+1000005,n)-a]); } return 0;}
0 0
- hdoj-5878-I Count Two Three
- hdoj 5878 I Count Two Three
- 5878 I Count Two Three
- I Count Two Three
- hdu 5878 I Count Two Three
- 【30.53%】【hdu 5878】I Count Two Three
- HDU 5878 I Count Two Three .
- HDU 5878 - I Count Two Three
- HDU 5878 I Count Two Three
- HDU-5878-I Count Two Three
- HDOJ 5878 I Count Two Three 【2016青岛网赛】暴力打表+二分枚举
- HDU5878-I Count Two Three
- HDU 5878 I Count Two Three (dfs+二分)
- hdu 5878 I Count Two Three(二分)
- HDU 5878 I Count Two Three 2016青岛网赛
- hdu 5878 I Count Two Three 丑数
- HDU 5878 I Count Two Three (DFS预处理 + 二分)
- HDU-5878 I Count Two Three(打表)
- [leetcode]561. Array Partition I
- 基于glist自定义自己的链表数据结构
- 几种设计模式
- dao层开发代码
- SELECT LAST_INSERT_ID() 的使用和注意事项
- hdoj 5878 I Count Two Three
- python爬虫(五)多页码
- android 实现aidl跨进程通信之一
- Mac安装TensorFlow
- 决策树--ID3算法
- RequestMapping的相关知识讲解(补)
- Windows2008 R2服务器配置TLS1.2方法
- 【EJB】Developing EJB Applications -- Chapter 2(创建企业级Bean项目)
- PAT A1086