T1.bug

可以求出s(x)的表达式,s(x)=9*pow(10,(x-1)/2)

然后可以看出sum(x)具有一定的规律,开头是(x-2+(x%2)),然后是一些7,最后是一个9

构造这样一个数,需要用到9的逆元,注意到9和23333互质,用欧拉定理求即可

单次询问复杂度O(logn)

#include<iostream>
#include<cstdlib>
#include<cstdio>

using namespace std;

typedef long long ll;

inline ll rd(){
    ll ret=0,f=1;char c;
    while(c=getchar(),!isdigit(c))f=c=='-'?-1:1;
    while(isdigit(c))ret=ret*10+c-'0',c=getchar();
    return ret*f;
}

const int MOD = 233333;
const ll inv = 29892;
ll qpow(ll x,ll y){
    register ll ret=1ll;
    while(y){
        if(y&1)(ret*=x)%=MOD;
        (x*=x)%=MOD;
        y>>=1ll;
    }
    return ret;
}

ll T,n;

void out(ll x){
    if(!x)return;
    out(x/10);
    putchar(x%10+'0');
}

inline void solve(){
    n=rd();
    ll v=(n-2+(n&1));
    ll tmp=qpow(10ll,(v/2)+1);
    ll ans=(tmp*v);
    tmp--;
    if(tmp<0)tmp+=MOD;
    tmp*=181482ll;
    ans+=tmp;
    out((ans+2)%MOD);
    putchar('\n');
//    printf("%lld\n",(ans+2)%MOD); 
}

int main(){
    freopen("bug.in","r",stdin);
    freopen("bug.out","w",stdout);
    T=rd();
    while(T--)solve();
    return 0;
}
View Code

相关文章:

  • 2020-11-04
  • 2018-10-28
  • 2021-10-17
  • 2021-06-27
  • 2021-08-09
  • 2021-11-08
  • 2021-12-21
  • 2021-12-12
猜你喜欢
  • 2021-11-22
  • 2021-12-25
  • 2021-07-21
  • 2022-12-23
  • 2021-10-08
  • 2021-08-09
相关资源
相似解决方案