QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214368#7068. Lucky SequenceISYRHHWA 1936ms9608kbC++142.5kb2023-10-14 19:08:212023-10-14 19:08:21

Judging History

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

  • [2023-10-14 19:08:21]
  • 评测
  • 测评结果:WA
  • 用时:1936ms
  • 内存:9608kb
  • [2023-10-14 19:08:21]
  • 提交

answer

#include<bits/stdc++.h>
#include<immintrin.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define FOR(i,a,b) for(int i=a,i##i=b;i<=i##i;++i)
#define ROF(i,a,b) for(int i=a,i##i=b;i>=i##i;--i)
typedef uint32_t u32;
typedef uint64_t u64;
using namespace std;
const int L=1e5,N=1.7e5+7,mod=998244353;
const double FK=(sqrt(5)+1)/2;
#define Load(ptr) (_mm256_loadu_si256((__m256i*)(ptr)))
#define Store(ptr, __A) _mm256_storeu_si256((__m256i*)(ptr), __A)
namespace Cirno_loves_Reimu{
	char buf[1<<20],obuf[1<<20],*p1,*p2,*p3=obuf;
	#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
	#define putchar(x) (p3-obuf<1000000)?(*p3++=x):(fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=x)
	inline int read(){
		int x=0;bool f=0;
		char c=getchar();
		while(!isdigit(c)&&c!='-')c=getchar();
		if(c=='-')f=1,c=getchar();
		while(isdigit(c))x=x*10+c-'0',c=getchar();
		return f?-x:x;
	}
	void write(u64 x){
		if(x<0)putchar('-'),x=-x;
		static char buf[15];
		static int len=-1;
		do buf[++len]=x%10+48,x/=10;while(x);
		while(len>=0)putchar(buf[len]),--len;
		putchar('\n');
	}
	#undef getchar
	#undef putchar
}using namespace Cirno_loves_Reimu;
inline u64 qpow(u64 a,u64 b){
	u64 R=1;
	for(;b;b>>=1,a=a*a%mod)if(b&1)R=R*a%mod;
	return R;
}
inline u32 to(u32 a){return (u32)((((u64)a)<<32)%998244353);}
inline u32 redc(u64 a){
	u32 b=(u32)a*998244351;
	u64 c=a+(u64)b*998244353;
	return (u32)(c>>32);
}
__attribute__((always_inline)) __m256i redc(__m256i a){
	__m256i b=_mm256_mul_epu32(a, _mm256_set1_epi32(998244351));
	__m256i c=_mm256_add_epi64(a, _mm256_mul_epu32(b, _mm256_set1_epi32(998244353)));
	return _mm256_srli_epi64(c,32);
}
int a[N];
u64 ans[N],f[N],num[N+1],I[]={to(1),to(1),to(1),to(1)};
void work(int i){
	int j=i;
	auto P=Load(I);
	u64 tmp[]={0,0,0,0};
	for(;j>3;j-=4){
		auto Y=redc(
			_mm256_add_epi64(
				_mm256_mul_epu32(
					Load(f+j-3),
					P
				),
				_mm256_mul_epu32(
					Load(f+j-4),
					Load(num+N-(a[i]-j+4))
				)
			)
		);
		Store(f+j-3,Y);
		Store(tmp,_mm256_add_epi64(Y,Load(tmp)));
	}
	FOR(k,0,3)ans[i]+=tmp[k];
	for(;j;--j){
		f[j]=redc(to(f[j])+f[j-1]*to(a[i]-j+1ll));
		ans[i]+=f[j];
	}
	ans[i]=redc(ans[i]+to(1));
}
signed main(){
	// freopen("dt.in","r",stdin);
	// freopen("dt.out","w",stdout);
	FOR(i,0,L)a[i]=(int)floor(FK*i);
	FOR(i,0,N)num[i]=to(N-i);
	f[0]=to(1);
	FOR(i,1,L)work(i);
	int T=read();
	while(T--)write(ans[read()]);
	fwrite(obuf,p3-obuf,1,stdout);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1748ms
memory: 8908kb

input:

5
1
2
3
4
5

output:

2
7
27
141
919

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 1745ms
memory: 8460kb

input:

1
100000

output:

757797613

result:

ok single line: '757797613'

Test #3:

score: 0
Accepted
time: 1743ms
memory: 9608kb

input:

1000
22568
59901
32625
77159
20665
98646
44928
96592
11443
88137
53705
90354
41583
60817
91696
66427
88639
6813
93000
13395
94112
62534
71965
21812
32169
82345
98958
16560
82042
53679
34636
20843
58907
12943
49049
68406
95730
52351
31702
42849
75524
28355
87441
3977
19409
26840
73924
75239
13883
944...

output:

512283284
732335762
162105871
244853136
93946059
351609654
670047232
235011092
817841037
663728573
178057637
545578765
823475841
179802724
754488058
21427077
368516001
755976516
332817809
895573832
392503381
281753219
807154049
697506532
558401292
682309547
498678317
420405486
355816470
941769776
77...

result:

ok 1000 lines

Test #4:

score: 0
Accepted
time: 1732ms
memory: 8680kb

input:

1000
9036
1921
59088
29263
53830
77915
67459
59238
72694
29746
32438
7567
25267
26295
39332
67958
7573
70442
27833
2712
27455
71660
79485
61606
11385
52165
96451
52784
25154
17847
23378
64935
92207
633
33324
34080
62726
79312
36738
25534
61256
83134
45722
87124
92548
29778
90065
90708
14206
55949
11...

output:

887375738
185864495
684204616
940533366
214730721
427877381
537051774
241528143
914147368
257911534
646344438
595659017
689901164
259655462
989375542
601886315
831005775
362780664
447990250
770016429
392018535
361158668
339978840
93002231
731735636
791569625
280701332
89862683
787031441
263606571
79...

result:

ok 1000 lines

Test #5:

score: 0
Accepted
time: 1804ms
memory: 8488kb

input:

1000
18753
21822
39143
6714
68147
95863
39060
58705
95632
50357
4795
79518
59901
62662
99291
38704
84028
4237
48888
42300
9765
67389
84274
18166
71932
38845
83579
79872
21597
4398
99385
72717
89530
18304
91849
75851
41785
49049
62801
15609
86223
97168
20923
65866
138
34515
60476
68228
232
17730
6453...

output:

847853379
490142143
673596645
633463716
742615413
940771896
298370451
986022532
989886624
30063041
119774969
835085555
732335762
144917760
225716898
631456583
996772590
499376995
623307593
441444421
371565727
906287178
94408606
836398569
72091648
638263600
1668580
685924314
776387400
462260232
62128...

result:

ok 1000 lines

Test #6:

score: 0
Accepted
time: 1753ms
memory: 8536kb

input:

1000
9513
14175
55601
54182
68054
33647
72330
49716
77434
83984
61145
23443
29675
81854
56051
66132
21694
31969
52809
70725
96685
73465
73760
35841
62259
68786
50070
51114
28051
24156
59943
45754
36177
64459
50052
60986
50871
33936
48815
71534
67001
7951
14017
59979
3199
30048
71211
471
93958
74982
...

output:

248228171
617478841
724297497
536828530
837112925
567900010
953779955
766853711
779353623
744687738
169545852
681986171
540328169
325854664
499398139
421957212
468535573
62035110
623804049
17215982
986909702
1381863
287855436
730040477
487382960
491162791
417105311
303894823
726777088
198921466
8115...

result:

ok 1000 lines

Test #7:

score: 0
Accepted
time: 1705ms
memory: 8708kb

input:

1000
595
308
350
695
485
649
265
445
93
486
884
805
317
960
567
921
456
791
871
18
55
529
431
69
959
738
915
375
45
663
999
33
289
277
806
298
154
197
12
326
824
30
346
722
76
361
293
818
719
957
787
809
661
507
751
212
962
631
569
536
561
128
603
112
939
878
890
58
754
664
408
438
637
10
463
544
62...

output:

352785038
829829846
39575634
126040755
619499866
381691595
345092526
742931755
847329892
173347173
644103387
291336371
812680979
970778935
286583786
221641110
87302280
432217395
946634817
72328049
290512351
311359326
291312676
41951599
182614473
988877478
64733444
582927217
28337171
662340124
699540...

result:

ok 1000 lines

Test #8:

score: 0
Accepted
time: 1862ms
memory: 8368kb

input:

5000
3108
479
4147
4591
3406
2597
804
1866
2588
483
4617
1053
1688
3205
1701
62
221
2882
2522
737
3390
674
1342
316
3408
3629
742
2702
3196
3925
1477
668
3481
2949
4364
3980
1640
2074
866
4618
1417
194
1974
3013
4861
3433
730
4910
3962
1310
2233
1956
1796
1544
1824
2481
2106
4387
3580
2009
1104
865
...

output:

811145023
490241791
702731360
665593153
227447720
753826493
309609946
814480975
740657570
190657935
848212018
272405848
411866278
896971116
872110711
266006587
212101945
156873600
402193881
175850816
466147152
338801852
293987585
734927745
444768928
955370403
850280395
810632080
387790567
522296108
...

result:

ok 5000 lines

Test #9:

score: 0
Accepted
time: 1936ms
memory: 8336kb

input:

10000
4506
1218
6756
2702
8980
3053
4978
5425
752
848
1366
9354
9736
5621
7171
8691
2329
9621
549
6984
1256
2150
8848
1206
4098
7273
5851
628
7691
9884
7692
9437
269
9422
6310
738
6704
3517
7253
5823
6252
994
3179
871
6821
1972
47
8803
1451
1352
8929
6025
4306
1215
8455
3232
9232
7015
7389
1949
8612...

output:

824678440
653433658
352726779
810632080
448760348
974135082
106267916
317116073
449569904
639850813
595301743
685365656
434898268
165533795
459795155
480195116
4712339
826100316
309080081
541007291
484784260
850485526
291559803
716616440
409459581
51505304
978154883
744447406
864704215
857749367
335...

result:

ok 10000 lines

Test #10:

score: -100
Wrong Answer
time: 1769ms
memory: 8836kb

input:

50000
30139
9357
22016
23146
17573
40473
17256
44159
10840
33027
34006
25292
2522
26127
23709
6764
10182
1973
19232
40340
23057
6887
42462
28416
46337
37357
23724
44037
32611
12567
48215
6369
35321
16233
45712
2797
16235
28244
36019
11022
17669
49532
7218
40406
25222
16749
34921
2192
46664
18305
311...

output:

330862674
251042768
174291998
127471841
583159196
859026054
640820458
555388145
642223703
581692140
122867752
304841037
402193881
580968810
8043081
896581221
517973455
645552913
618894682
406913577
156838272
630874756
156497658
582281930
311207160
957873093
809717564
97471206
82484740
816302156
7650...

result:

wrong answer 25065th lines differ - expected: '1130', found: '998245483'