Submission #44990539
Source Code Expand
#include<cstdio>
#include<algorithm>
using namespace std;
#define Ed for(int i=h[x];~i;i=ne[i])
#define Ls(i,l,r) for(int i=l;i<r;++i)
#define Rs(i,l,r) for(int i=l;i>r;--i)
#define Le(i,l,r) for(int i=l;i<=r;++i)
#define Re(i,l,r) for(int i=l;i>=r;--i)
#define L(i,l) for(int i=0;i<l;++i)
#define E(i,l) for(int i=1;i<=l;++i)
#define W(t) while(t--)
#define Wh while
#define add(a,b) (a+=b)>=mod&&(a-=mod)
#define sub(a,b) (a-=b)<0&&(a+=mod)
typedef long long ll;
const int N=62,M=10,V=2,mod=998244353;
int f[N][V][V][V][M][M][M],a,b,c,high;
ll n;
signed main(){
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
scanf("%lld%d%d%d",&n,&a,&b,&c);
high=__lg(n)+1;
f[0][1][1][1][0][0][0]=1;
L(i, high){
bool now=n>>i&1;
L(f1, 2)
L(f2, 2)
L(f3, 2)
L(r1, a)
L(r2, b)
L(r3, c){
if(!f[i][f1][f2][f3][r1][r2][r3])continue;
L(n1, 2)
L(n2, 2)
L(n3, 2){
if((n1+n2+n3)&1)continue;
bool nf1=!now&&n1?0:(!n1&&now)||f1,nf2=!now&&n2?0:(!n2&&now)||f2,nf3=!now&&n3?0:(!n3&&now)||f3;
int nr1=(r1+(n1?1ll<<i:0))%a,nr2=(r2+(n2?1ll<<i:0))%b,nr3=(r3+(n3?1ll<<i:0))%c;
add(f[i+1][nf1][nf2][nf3][nr1][nr2][nr3],f[i][f1][f2][f3][r1][r2][r3]);
}
}
}
ll A=b*c/__gcd(b,c),B=a*c/__gcd(a,c),C=b*a/__gcd(b,a),tot=(n/A+n/B+n/C+1)%mod,ans=f[high][1][1][1][0][0][0];
sub(ans,tot);
printf("%lld",ans);
return 0;
}
Submission Info
Submission Time
2023-08-27 11:27:52+0900
Task
F - Nim
User
WUSICHENG
Language
C++ 20 (gcc 12.2)
Score
500
Code Size
1881 Byte
Status
AC
Exec Time
14 ms
Memory
3568 KiB
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:24:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%lld%d%d%d",&n,&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
500 / 500
Status
Set Name
Test Cases
Sample
sample_01.txt, sample_02.txt, sample_03.txt
All
random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, random_39.txt, random_40.txt, random_41.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name
Status
Exec Time
Memory
random_01.txt
AC
3 ms
3236 KiB
random_02.txt
AC
2 ms
3360 KiB
random_03.txt
AC
2 ms
3376 KiB
random_04.txt
AC
4 ms
3308 KiB
random_05.txt
AC
3 ms
3264 KiB
random_06.txt
AC
2 ms
3396 KiB
random_07.txt
AC
5 ms
3432 KiB
random_08.txt
AC
4 ms
3388 KiB
random_09.txt
AC
2 ms
3120 KiB
random_10.txt
AC
2 ms
3440 KiB
random_11.txt
AC
2 ms
3352 KiB
random_12.txt
AC
2 ms
3428 KiB
random_13.txt
AC
2 ms
3336 KiB
random_14.txt
AC
1 ms
3340 KiB
random_15.txt
AC
4 ms
3252 KiB
random_16.txt
AC
1 ms
3360 KiB
random_17.txt
AC
1 ms
3224 KiB
random_18.txt
AC
4 ms
3476 KiB
random_19.txt
AC
1 ms
3360 KiB
random_20.txt
AC
2 ms
3264 KiB
random_21.txt
AC
2 ms
3284 KiB
random_22.txt
AC
5 ms
3440 KiB
random_23.txt
AC
1 ms
3220 KiB
random_24.txt
AC
5 ms
3420 KiB
random_25.txt
AC
12 ms
3032 KiB
random_26.txt
AC
7 ms
3452 KiB
random_27.txt
AC
14 ms
3372 KiB
random_28.txt
AC
11 ms
3568 KiB
random_29.txt
AC
6 ms
3208 KiB
random_30.txt
AC
14 ms
3436 KiB
random_31.txt
AC
11 ms
3352 KiB
random_32.txt
AC
10 ms
3548 KiB
random_33.txt
AC
11 ms
3232 KiB
random_34.txt
AC
10 ms
3464 KiB
random_35.txt
AC
14 ms
3328 KiB
random_36.txt
AC
12 ms
3384 KiB
random_37.txt
AC
0 ms
1664 KiB
random_38.txt
AC
0 ms
1672 KiB
random_39.txt
AC
7 ms
3392 KiB
random_40.txt
AC
1 ms
2904 KiB
random_41.txt
AC
1 ms
1904 KiB
sample_01.txt
AC
0 ms
1716 KiB
sample_02.txt
AC
1 ms
3220 KiB
sample_03.txt
AC
2 ms
3316 KiB