QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21545 | #2850. 蛋糕 | s8194272# | AC ✓ | 10ms | 3664kb | C++14 | 1.7kb | 2022-03-07 14:54:17 | 2022-05-08 03:37:00 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#define int long long
#define fi first
#define se second
#define max Max
#define min Min
#define abs Abs
#define lc (x<<1)
#define rc (x<<1|1)
#define mid ((l+r)>>1)
#define pb(x) push_back(x)
#define lowbit(x) (x&(-x))
#define fan(x) (((x-1)^1)+1)
#define mp(x,y) make_pair(x,y)
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
#define INF 0x3f3f3f3f
using namespace std;
inline int read()
{
int ans=0,f=1;
char c=getchar();
while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
return ans*f;
}
inline void write(int x)
{
if(x<0) putchar('-'),x=-x;
if(x/10) write(x/10);
putchar((char)(x%10)+'0');
}
template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a<b?a:b;}
template<typename T,typename TT> inline T Max(T a,TT b){return a<b?b:a;}
const int mod=2148473648;
int t,n=4,a[10],dp[10][10];
signed main()
{
t=read();
while(t--)
{
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;++i)
a[i]=read();
dp[0][0]=1;
for(int i=1;i<=n;++i)
if(a[i]==1)
{
for(int j=0;j<=n*2;++j)
dp[i][j+2]=(dp[i][j+2]+dp[i-1][j])%mod;
}
else
{
for(int j=0;j<=n*2;++j)
{
dp[i][j]=(dp[i][j]+dp[i-1][j]*(a[i]-2))%mod;
dp[i][j+1]=(dp[i][j+1]+dp[i-1][j]*2)%mod;
}
}
for(int i=0;i<=n*2;++i)
write(dp[n][i]),putchar(' ');
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 10ms
memory: 3664kb
input:
9999 18429 66560 1 13694 48994 1 16287 10018 26028 52162 14916 1 30285 52396 33384 55269 65461 96967 74820 73364 55054 70162 1 1 97285 88897 39444 35439 61069 20048 35664 1 21838 22945 6244 79240 46316 82624 33318 31522 90387 93765 7568 97379 22273 74037 1255 91257 67961 28295 1 36263 20958 87638 59...
output:
0 0 278697304 483210476 394708 8 0 0 0 0 0 939058608 754824656 301172 8 0 0 0 0 0 928825136 750217032 372400 8 0 0 0 1239780156 506705424 73742516 1370608 16 0 0 0 0 1867092428 2145345144 1816812716 2484832 16 0 0 0 0 0 0 0 0 1713974672 250424 4 0 0 1222501394 1134629934 1413163092 2088456 16 ...
result:
ok 9999 lines