QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#736241#7044. Easy Problemgyydp123_LIMAC ✓37ms5252kbC++201.8kb2024-11-12 08:16:292024-11-12 08:16:29

Judging History

This is the latest submission verdict.

  • [2024-11-12 08:16:29]
  • Judged
  • Verdict: AC
  • Time: 37ms
  • Memory: 5252kb
  • [2024-11-12 08:16:29]
  • Submitted

answer

//Start: 2024-11-12 07:53:25
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt, __func__, __LINE__, ##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=59964251,phi=59870352;
ll ksm(ll a,int k){ll s=1;while(k){if(k&1) s=s*a%mod;a=a*a%mod;k>>=1;}return s;}
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline int read(){
  char ch=getchar();int x=0,f=1;
  while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
  while(ch>='0'&&ch<='9')
    x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
  return x*f;
}
int p[N],tot,mu[N];bool vis[N];
void init(int n){
  mu[1]=1;
  For(i,2,n){
    if(!vis[i]) p[++tot]=i,mu[i]=-1;
    For(j,1,tot){
      int t=i*p[j];if(t>n) break;
      vis[t]=1;mu[t]=-mu[i];
      if(i%p[j]==0){mu[t]=0;break;}
    }
  }
}
char s[N];ll pw;bool flg;
int d,m,k;ll sum[N];
int gcd(int a,int b){
  if(!a||!b) return a|b;
  int az=__builtin_ctz(a);
  int bz=__builtin_ctz(b);
  int z=min(az,bz);
  b>>=bz;
  while(a){
    a>>=az;
    int diff=b-a;
    az=__builtin_ctz(diff);
    if(a<b) b=a;
    a=abs(diff);
  }return b<<z;
}
ll trs(ll x){
  if(gcd(x,mod)==1) return ksm(x,pw);
  return ksm(x,pw+(flg?phi:0));
}
void ljy(){
  scanf("%s",s+1);
  m=read();d=read();k=read();m/=d;
  For(i,1,m) sum[i]=(sum[i-1]+ksm(i,k))%mod;
  int len=strlen(s+1);pw=flg=0;
  For(i,1,len){
    pw=pw*10+s[i]-'0';
    if(pw>=phi) flg=1,pw%=phi;
  }ll ans=0;
  For(i,1,m) ans=(ans+(mod+mu[i])*trs(ksm(i,k)*sum[m/i]%mod))%mod;
  printf("%lld\n",ans*trs(ksm(d,k))%mod);
}
signed LJY(){init(N-5);int T=read();while(T--) ljy();}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4388kb

input:

1
3 3 3 1

output:

27

result:

ok 1 number(s): "27"

Test #2:

score: 0
Accepted
time: 37ms
memory: 5252kb

input:

20
3 3 3 1
9109799336 6801 6178 261710951
7273901587 15151 659 409734533
2867553837 42265 22783 503178763
9393025453 49771 40281 632206641
8546649695 27578 8371 768172206
2453202595 27622 5445 542869700
334181849 61345 20134 20459578
2059563445 3141 1828 946541278
7244386143 69641 50850 906938712
89...

output:

27
20547372
8512644
59186649
51209646
43975644
44588858
9043868
30587070
44698073
3989303
8179341
37852631
19910063
45874282
20815913
47317834
21091711
47365734
49692924

result:

ok 20 numbers

Extra Test:

score: 0
Extra Test Passed