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

1853: [Scoi2010]幸运数字[容斥原理]

时间:2017-03-26 19:50:38      阅读:1074      评论:0      收藏:0      [点我收藏+]

标签:init   stdin   main   ble   ace   sam   blog   ever   clear   

1853: [Scoi2010]幸运数字

Time Limit: 2 Sec  Memory Limit: 64 MB
Submit: 2405  Solved: 887
[Submit][Status][Discuss]

Description

在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的“幸运号码”是十进制表示中只包含数字6和8的那些号码,比如68,666,888都是“幸运号码”!但是这种“幸运号码”总是太少了,比如在[1,100]的区间内就只有6个(6,8,66,68,86,88),于是他又定义了一种“近似幸运号码”。lxhgww规定,凡是“幸运号码”的倍数都是“近似幸运号码”,当然,任何的“幸运号码”也都是“近似幸运号码”,比如12,16,666都是“近似幸运号码”。 现在lxhgww想知道在一段闭区间[a, b]内,“近似幸运号码”的个数。

Input

输入数据是一行,包括2个数字a和b

Output

输出数据是一行,包括1个数字,表示在闭区间[a, b]内“近似幸运号码”的个数

Sample Input

【样例输入1】
1 10
【样例输入2】
1234 4321

Sample Output

【样例输出1】
2
【样例输出2】
809

HINT

【数据范围】
对于30%的数据,保证1 < =a < =b < =1000000
对于100%的数据,保证1 < =a < =b < =10000000000

Source

Day1

/*
    一个非常显然的事实就是幸运号码不会太多。把表打出来,就会发现在10^10以内的幸运数只有2404个
  这个时候一个非常显然的想法就是对这些数进行容斥,即加上每个数的倍数个数,减去两个数的lcm的倍数个数,加上三个的lcm的倍数个数,……以此类推。
  这样的复杂度显然是不对的,理论上可达O(2^x),其中xx为幸运数个数。但是由于多个数的倍数不能超过右边界,就可以剪枝,实际复杂度低了不知道多少。
  但是这样时间不够。我们还可以对幸运数进行处理,将其中是另外的幸运数的倍数的数给去掉。这样可以将需要考虑的数的个数减掉一半左右。
  最后还有一个小优化,那就是将最后需要处理的幸运数按从大到小排好序。这样可以让乘积尽早变得更大,可以减掉许多不必要的计算。
  加了上述优化,就差不多可以AC了。
*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#define set(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const int N=3000;
typedef long long ll;
ll l,r,now,ci,ans;
ll num,cnt,a[N],b[N];
void init(ll x){
    if(x>r) return ;
    a[num++]=x;
    init(x*10+6);
    init(x*10+8);
}
void dfs(ll x){
    if(x>cnt){
        if(!ci) return ;
        if(ci&1) ans+=r/now-(l-1)/now;
        else ans-=r/now-(l-1)/now;
        return ;
    }
    dfs(x+1);
    ll tx=now;
    now=now/__gcd(now,b[x]);ci++;
    if((double)now*b[x]<=r){
        now*=b[x];
        dfs(x+1);
    }
    ci--;now=tx;
}
int main(){
    set(luckynumber);
    cin>>l>>r;
    init(0);num--;
    sort(a+1,a+num+1);
    for(int i=1;i<=num;i++){
        b[++cnt]=a[i];
        for(int j=1;j<cnt;j++){
            if(!(a[i]%b[j])){
                cnt--;break;
            }
        }
    }
    reverse(b+1,b+cnt+1);
    now=1;
    dfs(1);
    cout<<ans;
    return 0;
}
/*30分hash 
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define set(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
typedef long long ll;
ll a,b,n;
ll list[3000]={6LL,8LL,66LL,68LL,86LL,88LL,666LL,668LL,686LL,688LL,866LL,868LL,886LL,888LL,6666LL,6668LL,6686LL,6688LL,6866LL,6868LL,6886LL,6888LL,8666LL,8668LL,8686LL,8688LL,8866LL,8868LL,8886LL,8888LL,66666LL,66668LL,66686LL,66688LL,66866LL,66868LL,66886LL,66888LL,68666LL,68668LL,68686LL,68688LL,68866LL,68868LL,68886LL,68888LL,86666LL,86668LL,86686LL,86688LL,86866LL,86868LL,86886LL,86888LL,88666LL,88668LL,88686LL,88688LL,88866LL,88868LL,88886LL,88888LL,666666LL,666668LL,666686LL,666688LL,666866LL,666868LL,666886LL,666888LL,668666LL,668668LL,668686LL,668688LL,668866LL,668868LL,668886LL,668888LL,686666LL,686668LL,686686LL,686688LL,686866LL,686868LL,686886LL,686888LL,688666LL,688668LL,688686LL,688688LL,688866LL,688868LL,688886LL,688888LL,866666LL,866668LL,866686LL,866688LL,866866LL,866868LL,866886LL,866888LL,868666LL,868668LL,868686LL,868688LL,868866LL,868868LL,868886LL,868888LL,886666LL,886668LL,886686LL,886688LL,886866LL,886868LL,886886LL,886888LL,888666LL,888668LL,888686LL,888688LL,888866LL,888868LL,888886LL,888888LL,6666666LL,6666668LL,6666686LL,6666688LL,6666866LL,6666868LL,6666886LL,6666888LL,6668666LL,6668668LL,6668686LL,6668688LL,6668866LL,6668868LL,6668886LL,6668888LL,6686666LL,6686668LL,6686686LL,6686688LL,6686866LL,6686868LL,6686886LL,6686888LL,6688666LL,6688668LL,6688686LL,6688688LL,6688866LL,6688868LL,6688886LL,6688888LL,6866666LL,6866668LL,6866686LL,6866688LL,6866866LL,6866868LL,6866886LL,6866888LL,6868666LL,6868668LL,6868686LL,6868688LL,6868866LL,6868868LL,6868886LL,6868888LL,6886666LL,6886668LL,6886686LL,6886688LL,6886866LL,6886868LL,6886886LL,6886888LL,6888666LL,6888668LL,6888686LL,6888688LL,6888866LL,6888868LL,6888886LL,6888888LL,8666666LL,8666668LL,8666686LL,8666688LL,8666866LL,8666868LL,8666886LL,8666888LL,8668666LL,8668668LL,8668686LL,8668688LL,8668866LL,8668868LL,8668886LL,8668888LL,8686666LL,8686668LL,8686686LL,8686688LL,8686866LL,8686868LL,8686886LL,8686888LL,8688666LL,8688668LL,8688686LL,8688688LL,8688866LL,8688868LL,8688886LL,8688888LL,8866666LL,8866668LL,8866686LL,8866688LL,8866866LL,8866868LL,8866886LL,8866888LL,8868666LL,8868668LL,8868686LL,8868688LL,8868866LL,8868868LL,8868886LL,8868888LL,8886666LL,8886668LL,8886686LL,8886688LL,8886866LL,8886868LL,8886886LL,8886888LL,8888666LL,8888668LL,8888686LL,8888688LL,8888866LL,8888868LL,8888886LL,8888888LL,66666666LL,66666668LL,66666686LL,66666688LL,66666866LL,66666868LL,66666886LL,66666888LL,66668666LL,66668668LL,66668686LL,66668688LL,66668866LL,66668868LL,66668886LL,66668888LL,66686666LL,66686668LL,66686686LL,66686688LL,66686866LL,66686868LL,66686886LL,66686888LL,66688666LL,66688668LL,66688686LL,66688688LL,66688866LL,66688868LL,66688886LL,66688888LL,66866666LL,66866668LL,66866686LL,66866688LL,66866866LL,66866868LL,66866886LL,66866888LL,66868666LL,66868668LL,66868686LL,66868688LL,66868866LL,66868868LL,66868886LL,66868888LL,66886666LL,66886668LL,66886686LL,66886688LL,66886866LL,66886868LL,66886886LL,66886888LL,66888666LL,66888668LL,66888686LL,66888688LL,66888866LL,66888868LL,66888886LL,66888888LL,68666666LL,68666668LL,68666686LL,68666688LL,68666866LL,68666868LL,68666886LL,68666888LL,68668666LL,68668668LL,68668686LL,68668688LL,68668866LL,68668868LL,68668886LL,68668888LL,68686666LL,68686668LL,68686686LL,68686688LL,68686866LL,68686868LL,68686886LL,68686888LL,68688666LL,68688668LL,68688686LL,68688688LL,68688866LL,68688868LL,68688886LL,68688888LL,68866666LL,68866668LL,68866686LL,68866688LL,68866866LL,68866868LL,68866886LL,68866888LL,68868666LL,68868668LL,68868686LL,68868688LL,68868866LL,68868868LL,68868886LL,68868888LL,68886666LL,68886668LL,68886686LL,68886688LL,68886866LL,68886868LL,68886886LL,68886888LL,68888666LL,68888668LL,68888686LL,68888688LL,68888866LL,68888868LL,68888886LL,68888888LL,86666666LL,86666668LL,86666686LL,86666688LL,86666866LL,86666868LL,86666886LL,86666888LL,86668666LL,86668668LL,86668686LL,86668688LL,86668866LL,86668868LL,86668886LL,86668888LL,86686666LL,86686668LL,86686686LL,86686688LL,86686866LL,86686868LL,86686886LL,86686888LL,86688666LL,86688668LL,86688686LL,86688688LL,86688866LL,86688868LL,86688886LL,86688888LL,86866666LL,86866668LL,86866686LL,86866688LL,86866866LL,86866868LL,86866886LL,86866888LL,86868666LL,86868668LL,86868686LL,86868688LL,86868866LL,86868868LL,86868886LL,86868888LL,86886666LL,86886668LL,86886686LL,86886688LL,86886866LL,86886868LL,86886886LL,86886888LL,86888666LL,86888668LL,86888686LL,86888688LL,86888866LL,86888868LL,86888886LL,86888888LL,88666666LL,88666668LL,88666686LL,88666688LL,88666866LL,88666868LL,88666886LL,88666888LL,88668666LL,88668668LL,88668686LL,88668688LL,88668866LL,88668868LL,88668886LL,88668888LL,88686666LL,88686668LL,88686686LL,88686688LL,88686866LL,88686868LL,88686886LL,88686888LL,88688666LL,88688668LL,88688686LL,88688688LL,88688866LL,88688868LL,88688886LL,88688888LL,88866666LL,88866668LL,88866686LL,88866688LL,88866866LL,88866868LL,88866886LL,88866888LL,88868666LL,88868668LL,88868686LL,88868688LL,88868866LL,88868868LL,88868886LL,88868888LL,88886666LL,88886668LL,88886686LL,88886688LL,88886866LL,88886868LL,88886886LL,88886888LL,88888666LL,88888668LL,88888686LL,88888688LL,88888866LL,88888868LL,88888886LL,88888888LL,666666666LL,666666668LL,666666686LL,666666688LL,666666866LL,666666868LL,666666886LL,666666888LL,666668666LL,666668668LL,666668686LL,666668688LL,666668866LL,666668868LL,666668886LL,666668888LL,666686666LL,666686668LL,666686686LL,666686688LL,666686866LL,666686868LL,666686886LL,666686888LL,666688666LL,666688668LL,666688686LL,666688688LL,666688866LL,666688868LL,666688886LL,666688888LL,666866666LL,666866668LL,666866686LL,666866688LL,666866866LL,666866868LL,666866886LL,666866888LL,666868666LL,666868668LL,666868686LL,666868688LL,666868866LL,666868868LL,666868886LL,666868888LL,666886666LL,666886668LL,666886686LL,666886688LL,666886866LL,666886868LL,666886886LL,666886888LL,666888666LL,666888668LL,666888686LL,666888688LL,666888866LL,666888868LL,666888886LL,666888888LL,668666666LL,668666668LL,668666686LL,668666688LL,668666866LL,668666868LL,668666886LL,668666888LL,668668666LL,668668668LL,668668686LL,668668688LL,668668866LL,668668868LL,668668886LL,668668888LL,668686666LL,668686668LL,668686686LL,668686688LL,668686866LL,668686868LL,668686886LL,668686888LL,668688666LL,668688668LL,668688686LL,668688688LL,668688866LL,668688868LL,668688886LL,668688888LL,668866666LL,668866668LL,668866686LL,668866688LL,668866866LL,668866868LL,668866886LL,668866888LL,668868666LL,668868668LL,668868686LL,668868688LL,668868866LL,668868868LL,668868886LL,668868888LL,668886666LL,668886668LL,668886686LL,668886688LL,668886866LL,668886868LL,668886886LL,668886888LL,668888666LL,668888668LL,668888686LL,668888688LL,668888866LL,668888868LL,668888886LL,668888888LL,686666666LL,686666668LL,686666686LL,686666688LL,686666866LL,686666868LL,686666886LL,686666888LL,686668666LL,686668668LL,686668686LL,686668688LL,686668866LL,686668868LL,686668886LL,686668888LL,686686666LL,686686668LL,686686686LL,686686688LL,686686866LL,686686868LL,686686886LL,686686888LL,686688666LL,686688668LL,686688686LL,686688688LL,686688866LL,686688868LL,686688886LL,686688888LL,686866666LL,686866668LL,686866686LL,686866688LL,686866866LL,686866868LL,686866886LL,686866888LL,686868666LL,686868668LL,686868686LL,686868688LL,686868866LL,686868868LL,686868886LL,686868888LL,686886666LL,686886668LL,686886686LL,686886688LL,686886866LL,686886868LL,686886886LL,686886888LL,686888666LL,686888668LL,686888686LL,686888688LL,686888866LL,686888868LL,686888886LL,686888888LL,688666666LL,688666668LL,688666686LL,688666688LL,688666866LL,688666868LL,688666886LL,688666888LL,688668666LL,688668668LL,688668686LL,688668688LL,688668866LL,688668868LL,688668886LL,688668888LL,688686666LL,688686668LL,688686686LL,688686688LL,688686866LL,688686868LL,688686886LL,688686888LL,688688666LL,688688668LL,688688686LL,688688688LL,688688866LL,688688868LL,688688886LL,688688888LL,688866666LL,688866668LL,688866686LL,688866688LL,688866866LL,688866868LL,688866886LL,688866888LL,688868666LL,688868668LL,688868686LL,688868688LL,688868866LL,688868868LL,688868886LL,688868888LL,688886666LL,688886668LL,688886686LL,688886688LL,688886866LL,688886868LL,688886886LL,688886888LL,688888666LL,688888668LL,688888686LL,688888688LL,688888866LL,688888868LL,688888886LL,688888888LL,866666666LL,866666668LL,866666686LL,866666688LL,866666866LL,866666868LL,866666886LL,866666888LL,866668666LL,866668668LL,866668686LL,866668688LL,866668866LL,866668868LL,866668886LL,866668888LL,866686666LL,866686668LL,866686686LL,866686688LL,866686866LL,866686868LL,866686886LL,866686888LL,866688666LL,866688668LL,866688686LL,866688688LL,866688866LL,866688868LL,866688886LL,866688888LL,866866666LL,866866668LL,866866686LL,866866688LL,866866866LL,866866868LL,866866886LL,866866888LL,866868666LL,866868668LL,866868686LL,866868688LL,866868866LL,866868868LL,866868886LL,866868888LL,866886666LL,866886668LL,866886686LL,866886688LL,866886866LL,866886868LL,866886886LL,866886888LL,866888666LL,866888668LL,866888686LL,866888688LL,866888866LL,866888868LL,866888886LL,866888888LL,868666666LL,868666668LL,868666686LL,868666688LL,868666866LL,868666868LL,868666886LL,868666888LL,868668666LL,868668668LL,868668686LL,868668688LL,868668866LL,868668868LL,868668886LL,868668888LL,868686666LL,868686668LL,868686686LL,868686688LL,868686866LL,868686868LL,868686886LL,868686888LL,868688666LL,868688668LL,868688686LL,868688688LL,868688866LL,868688868LL,868688886LL,868688888LL,868866666LL,868866668LL,868866686LL,868866688LL,868866866LL,868866868LL,868866886LL,868866888LL,868868666LL,868868668LL,868868686LL,868868688LL,868868866LL,868868868LL,868868886LL,868868888LL,868886666LL,868886668LL,868886686LL,868886688LL,868886866LL,868886868LL,868886886LL,868886888LL,868888666LL,868888668LL,868888686LL,868888688LL,868888866LL,868888868LL,868888886LL,868888888LL,886666666LL,886666668LL,886666686LL,886666688LL,886666866LL,886666868LL,886666886LL,886666888LL,886668666LL,886668668LL,886668686LL,886668688LL,886668866LL,886668868LL,886668886LL,886668888LL,886686666LL,886686668LL,886686686LL,886686688LL,886686866LL,886686868LL,886686886LL,886686888LL,886688666LL,886688668LL,886688686LL,886688688LL,886688866LL,886688868LL,886688886LL,886688888LL,886866666LL,886866668LL,886866686LL,886866688LL,886866866LL,886866868LL,886866886LL,886866888LL,886868666LL,886868668LL,886868686LL,886868688LL,886868866LL,886868868LL,886868886LL,886868888LL,886886666LL,886886668LL,886886686LL,886886688LL,886886866LL,886886868LL,886886886LL,886886888LL,886888666LL,886888668LL,886888686LL,886888688LL,886888866LL,886888868LL,886888886LL,886888888LL,888666666LL,888666668LL,888666686LL,888666688LL,888666866LL,888666868LL,888666886LL,888666888LL,888668666LL,888668668LL,888668686LL,888668688LL,888668866LL,888668868LL,888668886LL,888668888LL,888686666LL,888686668LL,888686686LL,888686688LL,888686866LL,888686868LL,888686886LL,888686888LL,888688666LL,888688668LL,888688686LL,888688688LL,888688866LL,888688868LL,888688886LL,888688888LL,888866666LL,888866668LL,888866686LL,888866688LL,888866866LL,888866868LL,888866886LL,888866888LL,888868666LL,888868668LL,888868686LL,888868688LL,888868866LL,888868868LL,888868886LL,888868888LL,888886666LL,888886668LL,888886686LL,888886688LL,888886866LL,888886868LL,888886886LL,888886888LL,888888666LL,888888668LL,888888686LL,888888688LL,888888866LL,888888868LL,888888886LL,888888888LL,6666666666LL,6666666668LL,6666666686LL,6666666688LL,6666666866LL,6666666868LL,6666666886LL,6666666888LL,6666668666LL,6666668668LL,6666668686LL,6666668688LL,6666668866LL,6666668868LL,6666668886LL,6666668888LL,6666686666LL,6666686668LL,6666686686LL,6666686688LL,6666686866LL,6666686868LL,6666686886LL,6666686888LL,6666688666LL,6666688668LL,6666688686LL,6666688688LL,6666688866LL,6666688868LL,6666688886LL,6666688888LL,6666866666LL,6666866668LL,6666866686LL,6666866688LL,6666866866LL,6666866868LL,6666866886LL,6666866888LL,6666868666LL,6666868668LL,6666868686LL,6666868688LL,6666868866LL,6666868868LL,6666868886LL,6666868888LL,6666886666LL,6666886668LL,6666886686LL,6666886688LL,6666886866LL,6666886868LL,6666886886LL,6666886888LL,6666888666LL,6666888668LL,6666888686LL,6666888688LL,6666888866LL,6666888868LL,6666888886LL,6666888888LL,6668666666LL,6668666668LL,6668666686LL,6668666688LL,6668666866LL,6668666868LL,6668666886LL,6668666888LL,6668668666LL,6668668668LL,6668668686LL,6668668688LL,6668668866LL,6668668868LL,6668668886LL,6668668888LL,6668686666LL,6668686668LL,6668686686LL,6668686688LL,6668686866LL,6668686868LL,6668686886LL,6668686888LL,6668688666LL,6668688668LL,6668688686LL,6668688688LL,6668688866LL,6668688868LL,6668688886LL,6668688888LL,6668866666LL,6668866668LL,6668866686LL,6668866688LL,6668866866LL,6668866868LL,6668866886LL,6668866888LL,6668868666LL,6668868668LL,6668868686LL,6668868688LL,6668868866LL,6668868868LL,6668868886LL,6668868888LL,6668886666LL,6668886668LL,6668886686LL,6668886688LL,6668886866LL,6668886868LL,6668886886LL,6668886888LL,6668888666LL,6668888668LL,6668888686LL,6668888688LL,6668888866LL,6668888868LL,6668888886LL,6668888888LL,6686666666LL,6686666668LL,6686666686LL,6686666688LL,6686666866LL,6686666868LL,6686666886LL,6686666888LL,6686668666LL,6686668668LL,6686668686LL,6686668688LL,6686668866LL,6686668868LL,6686668886LL,6686668888LL,6686686666LL,6686686668LL,6686686686LL,6686686688LL,6686686866LL,6686686868LL,6686686886LL,6686686888LL,6686688666LL,6686688668LL,6686688686LL,6686688688LL,6686688866LL,6686688868LL,6686688886LL,6686688888LL,6686866666LL,6686866668LL,6686866686LL,6686866688LL,6686866866LL,6686866868LL,6686866886LL,6686866888LL,6686868666LL,6686868668LL,6686868686LL,6686868688LL,6686868866LL,6686868868LL,6686868886LL,6686868888LL,6686886666LL,6686886668LL,6686886686LL,6686886688LL,6686886866LL,6686886868LL,6686886886LL,6686886888LL,6686888666LL,6686888668LL,6686888686LL,6686888688LL,6686888866LL,6686888868LL,6686888886LL,6686888888LL,6688666666LL,6688666668LL,6688666686LL,6688666688LL,6688666866LL,6688666868LL,6688666886LL,6688666888LL,6688668666LL,6688668668LL,6688668686LL,6688668688LL,6688668866LL,6688668868LL,6688668886LL,6688668888LL,6688686666LL,6688686668LL,6688686686LL,6688686688LL,6688686866LL,6688686868LL,6688686886LL,6688686888LL,6688688666LL,6688688668LL,6688688686LL,6688688688LL,6688688866LL,6688688868LL,6688688886LL,6688688888LL,6688866666LL,6688866668LL,6688866686LL,6688866688LL,6688866866LL,6688866868LL,6688866886LL,6688866888LL,6688868666LL,6688868668LL,6688868686LL,6688868688LL,6688868866LL,6688868868LL,6688868886LL,6688868888LL,6688886666LL,6688886668LL,6688886686LL,6688886688LL,6688886866LL,6688886868LL,6688886886LL,6688886888LL,6688888666LL,6688888668LL,6688888686LL,6688888688LL,6688888866LL,6688888868LL,6688888886LL,6688888888LL,6866666666LL,6866666668LL,6866666686LL,6866666688LL,6866666866LL,6866666868LL,6866666886LL,6866666888LL,6866668666LL,6866668668LL,6866668686LL,6866668688LL,6866668866LL,6866668868LL,6866668886LL,6866668888LL,6866686666LL,6866686668LL,6866686686LL,6866686688LL,6866686866LL,6866686868LL,6866686886LL,6866686888LL,6866688666LL,6866688668LL,6866688686LL,6866688688LL,6866688866LL,6866688868LL,6866688886LL,6866688888LL,6866866666LL,6866866668LL,6866866686LL,6866866688LL,6866866866LL,6866866868LL,6866866886LL,6866866888LL,6866868666LL,6866868668LL,6866868686LL,6866868688LL,6866868866LL,6866868868LL,6866868886LL,6866868888LL,6866886666LL,6866886668LL,6866886686LL,6866886688LL,6866886866LL,6866886868LL,6866886886LL,6866886888LL,6866888666LL,6866888668LL,6866888686LL,6866888688LL,6866888866LL,6866888868LL,6866888886LL,6866888888LL,6868666666LL,6868666668LL,6868666686LL,6868666688LL,6868666866LL,6868666868LL,6868666886LL,6868666888LL,6868668666LL,6868668668LL,6868668686LL,6868668688LL,6868668866LL,6868668868LL,6868668886LL,6868668888LL,6868686666LL,6868686668LL,6868686686LL,6868686688LL,6868686866LL,6868686868LL,6868686886LL,6868686888LL,6868688666LL,6868688668LL,6868688686LL,6868688688LL,6868688866LL,6868688868LL,6868688886LL,6868688888LL,6868866666LL,6868866668LL,6868866686LL,6868866688LL,6868866866LL,6868866868LL,6868866886LL,6868866888LL,6868868666LL,6868868668LL,6868868686LL,6868868688LL,6868868866LL,6868868868LL,6868868886LL,6868868888LL,6868886666LL,6868886668LL,6868886686LL,6868886688LL,6868886866LL,6868886868LL,6868886886LL,6868886888LL,6868888666LL,6868888668LL,6868888686LL,6868888688LL,6868888866LL,6868888868LL,6868888886LL,6868888888LL,6886666666LL,6886666668LL,6886666686LL,6886666688LL,6886666866LL,6886666868LL,6886666886LL,6886666888LL,6886668666LL,6886668668LL,6886668686LL,6886668688LL,6886668866LL,6886668868LL,6886668886LL,6886668888LL,6886686666LL,6886686668LL,6886686686LL,6886686688LL,6886686866LL,6886686868LL,6886686886LL,6886686888LL,6886688666LL,6886688668LL,6886688686LL,6886688688LL,6886688866LL,6886688868LL,6886688886LL,6886688888LL,6886866666LL,6886866668LL,6886866686LL,6886866688LL,6886866866LL,6886866868LL,6886866886LL,6886866888LL,6886868666LL,6886868668LL,6886868686LL,6886868688LL,6886868866LL,6886868868LL,6886868886LL,6886868888LL,6886886666LL,6886886668LL,6886886686LL,6886886688LL,6886886866LL,6886886868LL,6886886886LL,6886886888LL,6886888666LL,6886888668LL,6886888686LL,6886888688LL,6886888866LL,6886888868LL,6886888886LL,6886888888LL,6888666666LL,6888666668LL,6888666686LL,6888666688LL,6888666866LL,6888666868LL,6888666886LL,6888666888LL,6888668666LL,6888668668LL,6888668686LL,6888668688LL,6888668866LL,6888668868LL,6888668886LL,6888668888LL,6888686666LL,6888686668LL,6888686686LL,6888686688LL,6888686866LL,6888686868LL,6888686886LL,6888686888LL,6888688666LL,6888688668LL,6888688686LL,6888688688LL,6888688866LL,6888688868LL,6888688886LL,6888688888LL,6888866666LL,6888866668LL,6888866686LL,6888866688LL,6888866866LL,6888866868LL,6888866886LL,6888866888LL,6888868666LL,6888868668LL,6888868686LL,6888868688LL,6888868866LL,6888868868LL,6888868886LL,6888868888LL,6888886666LL,6888886668LL,6888886686LL,6888886688LL,6888886866LL,6888886868LL,6888886886LL,6888886888LL,6888888666LL,6888888668LL,6888888686LL,6888888688LL,6888888866LL,6888888868LL,6888888886LL,6888888888LL,8666666666LL,8666666668LL,8666666686LL,8666666688LL,8666666866LL,8666666868LL,8666666886LL,8666666888LL,8666668666LL,8666668668LL,8666668686LL,8666668688LL,8666668866LL,8666668868LL,8666668886LL,8666668888LL,8666686666LL,8666686668LL,8666686686LL,8666686688LL,8666686866LL,8666686868LL,8666686886LL,8666686888LL,8666688666LL,8666688668LL,8666688686LL,8666688688LL,8666688866LL,8666688868LL,8666688886LL,8666688888LL,8666866666LL,8666866668LL,8666866686LL,8666866688LL,8666866866LL,8666866868LL,8666866886LL,8666866888LL,8666868666LL,8666868668LL,8666868686LL,8666868688LL,8666868866LL,8666868868LL,8666868886LL,8666868888LL,8666886666LL,8666886668LL,8666886686LL,8666886688LL,8666886866LL,8666886868LL,8666886886LL,8666886888LL,8666888666LL,8666888668LL,8666888686LL,8666888688LL,8666888866LL,8666888868LL,8666888886LL,8666888888LL,8668666666LL,8668666668LL,8668666686LL,8668666688LL,8668666866LL,8668666868LL,8668666886LL,8668666888LL,8668668666LL,8668668668LL,8668668686LL,8668668688LL,8668668866LL,8668668868LL,8668668886LL,8668668888LL,8668686666LL,8668686668LL,8668686686LL,8668686688LL,8668686866LL,8668686868LL,8668686886LL,8668686888LL,8668688666LL,8668688668LL,8668688686LL,8668688688LL,8668688866LL,8668688868LL,8668688886LL,8668688888LL,8668866666LL,8668866668LL,8668866686LL,8668866688LL,8668866866LL,8668866868LL,8668866886LL,8668866888LL,8668868666LL,8668868668LL,8668868686LL,8668868688LL,8668868866LL,8668868868LL,8668868886LL,8668868888LL,8668886666LL,8668886668LL,8668886686LL,8668886688LL,8668886866LL,8668886868LL,8668886886LL,8668886888LL,8668888666LL,8668888668LL,8668888686LL,8668888688LL,8668888866LL,8668888868LL,8668888886LL,8668888888LL,8686666666LL,8686666668LL,8686666686LL,8686666688LL,8686666866LL,8686666868LL,8686666886LL,8686666888LL,8686668666LL,8686668668LL,8686668686LL,8686668688LL,8686668866LL,8686668868LL,8686668886LL,8686668888LL,8686686666LL,8686686668LL,8686686686LL,8686686688LL,8686686866LL,8686686868LL,8686686886LL,8686686888LL,8686688666LL,8686688668LL,8686688686LL,8686688688LL,8686688866LL,8686688868LL,8686688886LL,8686688888LL,8686866666LL,8686866668LL,8686866686LL,8686866688LL,8686866866LL,8686866868LL,8686866886LL,8686866888LL,8686868666LL,8686868668LL,8686868686LL,8686868688LL,8686868866LL,8686868868LL,8686868886LL,8686868888LL,8686886666LL,8686886668LL,8686886686LL,8686886688LL,8686886866LL,8686886868LL,8686886886LL,8686886888LL,8686888666LL,8686888668LL,8686888686LL,8686888688LL,8686888866LL,8686888868LL,8686888886LL,8686888888LL,8688666666LL,8688666668LL,8688666686LL,8688666688LL,8688666866LL,8688666868LL,8688666886LL,8688666888LL,8688668666LL,8688668668LL,8688668686LL,8688668688LL,8688668866LL,8688668868LL,8688668886LL,8688668888LL,8688686666LL,8688686668LL,8688686686LL,8688686688LL,8688686866LL,8688686868LL,8688686886LL,8688686888LL,8688688666LL,8688688668LL,8688688686LL,8688688688LL,8688688866LL,8688688868LL,8688688886LL,8688688888LL,8688866666LL,8688866668LL,8688866686LL,8688866688LL,8688866866LL,8688866868LL,8688866886LL,8688866888LL,8688868666LL,8688868668LL,8688868686LL,8688868688LL,8688868866LL,8688868868LL,8688868886LL,8688868888LL,8688886666LL,8688886668LL,8688886686LL,8688886688LL,8688886866LL,8688886868LL,8688886886LL,8688886888LL,8688888666LL,8688888668LL,8688888686LL,8688888688LL,8688888866LL,8688888868LL,8688888886LL,8688888888LL,8866666666LL,8866666668LL,8866666686LL,8866666688LL,8866666866LL,8866666868LL,8866666886LL,8866666888LL,8866668666LL,8866668668LL,8866668686LL,8866668688LL,8866668866LL,8866668868LL,8866668886LL,8866668888LL,8866686666LL,8866686668LL,8866686686LL,8866686688LL,8866686866LL,8866686868LL,8866686886LL,8866686888LL,8866688666LL,8866688668LL,8866688686LL,8866688688LL,8866688866LL,8866688868LL,8866688886LL,8866688888LL,8866866666LL,8866866668LL,8866866686LL,8866866688LL,8866866866LL,8866866868LL,8866866886LL,8866866888LL,8866868666LL,8866868668LL,8866868686LL,8866868688LL,8866868866LL,8866868868LL,8866868886LL,8866868888LL,8866886666LL,8866886668LL,8866886686LL,8866886688LL,8866886866LL,8866886868LL,8866886886LL,8866886888LL,8866888666LL,8866888668LL,8866888686LL,8866888688LL,8866888866LL,8866888868LL,8866888886LL,8866888888LL,8868666666LL,8868666668LL,8868666686LL,8868666688LL,8868666866LL,8868666868LL,8868666886LL,8868666888LL,8868668666LL,8868668668LL,8868668686LL,8868668688LL,8868668866LL,8868668868LL,8868668886LL,8868668888LL,8868686666LL,8868686668LL,8868686686LL,8868686688LL,8868686866LL,8868686868LL,8868686886LL,8868686888LL,8868688666LL,8868688668LL,8868688686LL,8868688688LL,8868688866LL,8868688868LL,8868688886LL,8868688888LL,8868866666LL,8868866668LL,8868866686LL,8868866688LL,8868866866LL,8868866868LL,8868866886LL,8868866888LL,8868868666LL,8868868668LL,8868868686LL,8868868688LL,8868868866LL,8868868868LL,8868868886LL,8868868888LL,8868886666LL,8868886668LL,8868886686LL,8868886688LL,8868886866LL,8868886868LL,8868886886LL,8868886888LL,8868888666LL,8868888668LL,8868888686LL,8868888688LL,8868888866LL,8868888868LL,8868888886LL,8868888888LL,8886666666LL,8886666668LL,8886666686LL,8886666688LL,8886666866LL,8886666868LL,8886666886LL,8886666888LL,8886668666LL,8886668668LL,8886668686LL,8886668688LL,8886668866LL,8886668868LL,8886668886LL,8886668888LL,8886686666LL,8886686668LL,8886686686LL,8886686688LL,8886686866LL,8886686868LL,8886686886LL,8886686888LL,8886688666LL,8886688668LL,8886688686LL,8886688688LL,8886688866LL,8886688868LL,8886688886LL,8886688888LL,8886866666LL,8886866668LL,8886866686LL,8886866688LL,8886866866LL,8886866868LL,8886866886LL,8886866888LL,8886868666LL,8886868668LL,8886868686LL,8886868688LL,8886868866LL,8886868868LL,8886868886LL,8886868888LL,8886886666LL,8886886668LL,8886886686LL,8886886688LL,8886886866LL,8886886868LL,8886886886LL,8886886888LL,8886888666LL,8886888668LL,8886888686LL,8886888688LL,8886888866LL,8886888868LL,8886888886LL,8886888888LL,8888666666LL,8888666668LL,8888666686LL,8888666688LL,8888666866LL,8888666868LL,8888666886LL,8888666888LL,8888668666LL,8888668668LL,8888668686LL,8888668688LL,8888668866LL,8888668868LL,8888668886LL,8888668888LL,8888686666LL,8888686668LL,8888686686LL,8888686688LL,8888686866LL,8888686868LL,8888686886LL,8888686888LL,8888688666LL,8888688668LL,8888688686LL,8888688688LL,8888688866LL,8888688868LL,8888688886LL,8888688888LL,8888866666LL,8888866668LL,8888866686LL,8888866688LL,8888866866LL,8888866868LL,8888866886LL,8888866888LL,8888868666LL,8888868668LL,8888868686LL,8888868688LL,8888868866LL,8888868868LL,8888868886LL,8888868888LL,8888886666LL,8888886668LL,8888886686LL,8888886688LL,8888886866LL,8888886868LL,8888886886LL,8888886888LL,8888888666LL,8888888668LL,8888888686LL,8888888688LL,8888888866LL,8888888868LL,8888888886LL,8888888888LL,100000000000LL};
struct Thash{
    static const int N=2e6+5,MOD=1733333;
    ll tot,head[MOD+10],val[N],h[N],next[N];
    void clear(){tot=0;memset(head,0,sizeof head);}
    void insert(ll H,ll VAL){
        for(ll i=head[H%MOD];i;i=next[i]) if(h[i]==H){val[i]=VAL;return ;}
        h[++tot]=H;val[tot]=VAL;next[tot]=head[H%MOD];head[H%MOD]=tot;
    }
    ll get(ll H){
        for(ll i=head[H%MOD];i;i=next[i]) if(h[i]==H) return val[i];
        return 0;
    }
}M;
ll solve(ll lim){
    ll ans=0;
    M.clear();
    for(ll i=0;;i++){
        if(list[i]>lim) break;
        for(ll j=list[i];j<=lim;j+=list[i]){
            if(!M.get(j)){
                ans++;
                M.insert(j,1);
            }
        }
    }
    return ans;
}
int main(){
    set(luckynumber);
    cin>>a>>b;
    cout<<solve(b)-solve(a-1);
    return 0;
}*/

 

1853: [Scoi2010]幸运数字[容斥原理]

标签:init   stdin   main   ble   ace   sam   blog   ever   clear   

原文地址:http://www.cnblogs.com/shenben/p/6623515.html

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