QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#577115#6887. Data GenerationJZYZ#WA 147ms3736kbC++141.6kb2024-09-20 08:11:532024-09-20 08:11:54

Judging History

你现在查看的是最新测评结果

  • [2024-09-20 08:11:54]
  • 评测
  • 测评结果:WA
  • 用时:147ms
  • 内存:3736kb
  • [2024-09-20 08:11:53]
  • 提交

answer


#include<bits/stdc++.h>
using namespace std;
template <typename T>inline void read(T &x)
{
    x=0;char c=getchar();bool f=0;
    for(;c<'0'||c>'9';c=getchar())f|=(c=='-');
    for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c-'0');
    x=(f?-x:x);
}
typedef long long LL;
const  int mod = 998244353;
int Pow(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res=1ll*res*a%mod;
        a=1ll*a*a%mod;
        b>>=1;
    }
    return res;
}
struct mat
{
    int w[2][2];
};
mat operator *(mat A,mat B)
{
    mat C;
    for(int i=0;i<2;i++)
    for(int j=0;j<2;j++)
    {
        C.w[i][j]=0;
        for(int k=0;k<2;k++)
        C.w[i][j]=(C.w[i][j]+1ll*A.w[i][k]*B.w[k][j]%mod)%mod;
    }
    return  C;
}
mat Pow(mat A,LL B)
{
    mat res;
    for(int i=0;i<2;i++)
    for(int j=0;j<2;j++)
    res.w[i][j]=(i==j);
    while(B)
    {
        if(B&1)res=res*A;
        A=A*A;
        B>>=1;
    }
    return res;
}
int main()
{
    //freopen("Sum.in","r",stdin);
    //freopen("Sum.out","w",stdout);
    int T;
    read(T);
    while(T--)
    {
        LL n,m;
        read(n);read(m);
        int p=Pow(n%mod,mod-2);
        mat F,T;
        int x=(n%mod);
        for(int i=0;i<2;i++)
        for(int j=0;j<2;j++)
        F.w[i][j]=T.w[i][j]=0;
        T.w[0][1]=2ll*p%mod*p%mod;
        T.w[1][0]=2ll*(x-1)*p%mod*p%mod;
        T.w[1][1]=1ll*(1+1ll*(x-1)*(x-1)%mod)*p%mod*p%mod;
        T.w[0][0]=((1ll-T.w[0][1]-T.w[1][1]-T.w[1][0])%mod+mod)%mod;
        F.w[0][1]=1;
        F=F*Pow(T,m);
        int ans=F.w[0][0];
        printf("%lld\n",1ll*ans*x%mod);
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 147ms
memory: 3736kb

input:

100000
19491001 19491001
999999999449325353 939501148
400027352 999999998707619026
999999998353720210 999999999303057191
1879045722 1874448608
999999998385974740 1710466660
109045962 999999998020190078
999999998217418921 999999998898659805
999999999999986692 999999998389218199
351693073 2130408866
1...

output:

986677043
874784639
892682799
979669311
384999067
401298998
376022386
482688824
466223686
703514173
768317832
31430798
501964608
700206748
334770669
397756268
422153277
703053150
937596752
0
883253239
409307838
583555881
223615323
266858208
14990078
839369891
35427368
543893693
0
608035023
163296599...

result:

wrong answer 1st lines differ - expected: '79256423', found: '986677043'