51nod 1010 只包含因子2 3 5的数
来源:互联网 发布:游族网络股票诊断 编辑:程序博客网 时间:2024/06/02 07:30
题目链接:
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010
题解:
简单题,只要打表加二分,虽然自己的表打错了,结果错了半天。
代码:
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define met(a,b) memset(a,b,sizeof(a))#define inf 0x3f3f3f3ftypedef long long ll;const ll maxn = 1e18;ll num[50086];ll len;void init(){ len=0; for(ll i=1;i<=maxn;i*=2) for(ll j=1;i*j<=maxn;j*=3) for(ll k=1;i*j*k<=maxn;k*=5) { ll ans=i*j*k; num[len++]=ans; } sort(num,num+len);}int main(){ init(); ll t; cin>>t; while(t--) { ll n; cin>>n; ll left=1,right=len,mid=0; while(left<right) { mid=(left+right)>>1; if(num[mid]>=n) right=mid; else left=mid+1; } cout<<num[left]<<endl; }}
0 0
- 只包含因子2 3 5 的数----51Nod
- 51nod 1010 只包含因子2 3 5的数 (打表+二分)
- 51NOD 1010 只包含因子2 3 5的数(二分 + 预处理)
- 51nod 1010 只包含因子2 3 5的数
- 51nod:1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数(打表+二分)
- 51nod-1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数
- 51nod-1010 只包含因子2 3 5的数
- 51Nod 1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数
- 51nod-1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数【打表+二分】
- 51Nod--1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数
- 51nod 1010 只包含因子2 3 5的数(预处理+二分)
- 【python tkinter】登陆界面
- Client
- 第32篇 一对多自由控制语音(十一)及php AJAX
- 单链表
- asp.net发布网站错误
- 51nod 1010 只包含因子2 3 5的数
- 入门训练 A+B问题
- centOS 7 初次安装的许可问题
- 【Struts2】文件上传(一个文件和多个文件)
- 原码, 反码, 补码 详解
- PAT 1006 换个格式输出整数
- Cocos2d-x3.2与OpenGL渲染总结(一)Cocos2d-x3.2的渲染流程
- 二维码生成
- submit text3--emmet安装