hdu 5878
来源:互联网 发布:淘宝开学季活动 编辑:程序博客网 时间:2024/06/13 09:32
题意:
给出一个整数n
, 找出一个大于等于n
的最小整数m
, 使得m
可以表示为2a3b5c7d
.
思路:
预处理出所有形为2a3b5c7d
即可, 大概五千多个.然后用二分查找就可以了
#include <iostream>#include <cstring>#include <algorithm> using namespace std;typedef long long ll;ll ans[10000];ll Pow(int x,int num){ll aaa=1LL;for (int i=1;i<=num;i++){aaa=aaa*1LL*x;}return aaa;}int main(){int cnt=0;for (int i=0;i<=31;i++){for (int j=0;j<=19;j++){for (int k=0;k<=12;k++){for (int l=0;l<=11;l++){ll tmp=Pow(2,i)*Pow(3,j);if (tmp>1e9) break;tmp*=Pow(5,k);if (tmp>1e9) break;tmp*=Pow(7,l);if (tmp>1e9) break;ans[cnt++]=tmp;}}}}sort(ans,ans+cnt);int t;scanf("%d",&t);while(t--){ll n;scanf("%I64d",&n);int x=lower_bound(ans,ans+cnt,n)-ans;printf("%I64d\n",ans[x]);}return 0;}
0 0
- hdu 5878
- HDU 5878
- hdu 5878
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- Service几种情况介绍和使用
- Unity UGUI图文混排源码(三) -- 动态表情
- Mybatis之properties属性
- Spring原理-注入依赖的过程
- 全栈必备Linux 基础
- hdu 5878
- Servlet入门
- hdu 5883 (欧拉路,青岛网络赛)
- 第4周 项目3-- 单链表应用(2)
- JDBC的基本操作
- css基本知识点
- Leetcode 73 Set Matrix Zeroes
- Android Service完全解析,关于服务你所需知道的一切(上)
- 公有密钥和私有密钥加密