栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 3909 Lucky numbers

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 3909 Lucky numbers

#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<vector>using namespace std;typedef  __int64 lld;vector<lld> lu,res;int tot;void dfs(lld num,int de){    if(de==12) return ;    lu.push_back(num);    dfs(num*10+4,de+1);    dfs(num*10+7,de+1);}void dfs1(int x,lld num){        for(int i=x;i<lu.size();i++){        if(1e12/num<lu[i]) return;        res.push_back(num*lu[i]);        dfs1(i,num*lu[i]);    }}void init(){    lu.clear();res.clear();    dfs(4,0);    dfs(7,0);    sort(lu.begin(),lu.end());    dfs1(0,1);    sort(res.begin(),res.end());    tot=unique(res.begin(),res.end())-res.begin();}int main(){    init();    int t;    lld a,b;    scanf("%d",&t);    while(t--){        scanf("%I64d%I64d",&a,&b);        int l=lower_bound(res.begin(),res.begin()+tot,a)-res.begin();        int r=upper_bound(res.begin(),res.begin()+tot,b)-res.begin();        printf("%dn",r-l);    }}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/364824.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号