码迷,mamicode.com
首页 > 其他好文 > 详细

ZOJ3622 Magic Number(水题)

时间:2014-11-17 09:14:23      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:io   os   sp   for   on   代码   amp   ef   as   

分析:

举个例子xxx(三位数)为魔力数,则xxx|(xxx+1000*y),那么xxx|1000,这个就是结论

同理:四位数xxxx|10000,五位数xxxxx|100000

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#include<queue>
#include<cstring>
#include<algorithm>
typedef long long LL;
using namespace std;

const int maxn=600005;
LL p[maxn];
int main()
{
    LL a,b;
    while(~scanf("%lld%lld",&a,&b))
    {
        LL cnt=0;
        for(LL i=10;i<1000000000000;i*=10)
        {
            for(LL j=10;j>1;j--)
                if(i%j==0&&i/j>=i/10)p[cnt++]=i/j;
        }
        sort(p,p+cnt);
        LL ans=upper_bound(p,p+cnt,b)-lower_bound(p,p+cnt,a);
        printf("%lld\n",ans);
    }
    return 0;
}



ZOJ3622 Magic Number(水题)

标签:io   os   sp   for   on   代码   amp   ef   as   

原文地址:http://blog.csdn.net/u014569598/article/details/41203999

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!