QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#336034#8049. Equal SumslrherWA 1ms6008kbC++142.3kb2024-02-24 11:46:422024-02-24 11:46:42

Judging History

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

  • [2024-02-24 11:46:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6008kb
  • [2024-02-24 11:46:42]
  • 提交

answer

#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<bitset>
#include<vector>
#include<cstdio>
#include<random>
#include<complex>
#include<cstdlib>
#include<climits>
#include<iomanip>
#include<cstring>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
// #define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
// char buf[1<<21],*p1=buf,*p2=buf;
const long long _base=107374183;
int writetemp[30];
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;
    return x;
}
inline void write(int x)
{
    int t;
	int tot=(x==0);
    writetemp[1]=0;
	while(x) t=x/10,writetemp[++tot]=x-(t<<1)-(t<<3),x=t;
    for(int i=tot;i>=1;i--) putchar(writetemp[i]+'0');
    putchar('\n');
	return ;
}
const int mod=998244353;
int n,m;
long long dp[510][1010],lst[510][1010];
long long binpow(long long a,long long b)
{
    long long res=1;
    while(b)
    {
        if(b&1) res=(res*a)%mod;
        b>>=1,a=(a*a)%mod;
    }
    return res;
}
struct node
{
    int l,r;
}a[1000010],b[1000010];
int main()
{
    // freopen("s.out","r",stdin);
    // freopen("a.out","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
    for(int i=1;i<=m;i++) scanf("%d%d",&b[i].l,&b[i].r);
    long long inv=1;
    lst[0][500]=1;
	for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            for(int k=0;k<=500;k++) dp[j][k+a[i].l]+=lst[j][k],dp[j][k+a[i].r+1]+=mod-lst[j][k];
            for(int k=1;k<=1000;k++) (dp[j][k]+=dp[j][k-1])%=mod;
            for(int k=501;k<=1000;k++) dp[j+1][k-b[j+1].r]+=dp[j][k],dp[j+1][k-b[j+1].l+1]+=mod-dp[j][k];
        }
        inv=inv*binpow(a[i].r-a[i].l+1,mod-2)%mod;
        long long now=inv;
		for(int j=1;j<=m;j++)
        {
            now=now*binpow(b[j].r-b[j].l+1,mod-2)%mod;
            printf("%lld ",now*dp[j][500]%mod);
		}
        printf("\n");
        for(int j=0;j<=m;j++) for(int k=0;k<=1000;k++) lst[j][k]=dp[j][k],dp[j][k]=0;
	}
	return 0;
}
/*
*/

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6008kb

input:

2 3
1 2
2 3
1 4
2 2
1 3

output:

748683265 0 0 
811073537 748683265 582309206 

result:

wrong answer 1st numbers differ - expected: '2', found: '748683265'