Advertisement
Guest User

_ypc

a guest
May 25th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. const LL tt=1e9+7;
  5. const double l_2=log10(2.0);
  6. inline LL power(LL a,LL b){
  7.     LL ret=1,w=a%b;
  8.     while (b){
  9.         if (b&1)ret=(ret*w)%tt;
  10.         b>>=1,w=(w*w)%tt;
  11.     }
  12.     return ret;
  13. }
  14. LL n,l,ans_1,ans_2;
  15. inline LL tc(double x){
  16.     return x<0?0:trunc(x);
  17. }
  18. inline LL work_1(LL x,LL l){
  19.     double ret=0,xx=x,ll=log10((double)(l*1.0)),ll_1=log10((double)((l+1)*1.0));
  20.     for (double i=0;i<=x;i=i+1.0)
  21.     ret+=tc(i*l_2-ll)-tc(i*l_2-ll_1);
  22.     return trunc(ret)+(l<=2);
  23. }
  24. inline LL work_2(LL x){
  25.     return (power(2,x+2)-5+tt)%tt;
  26. }
  27.  
  28. int main(){
  29.     scanf("%lld%lld",&n,&l);
  30.     ans_1=work_1(n,l)+((l==4)||(l==8)),ans_2=work_2(ans_1);
  31.     printf("%lld\n%lld",ans_1,ans_2);
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement