QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108885#5352. 吉夫特myee100 ✓104ms3588kbC++113.7kb2023-05-26 21:06:212023-05-26 21:06:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-26 21:06:26]
  • 评测
  • 测评结果:100
  • 用时:104ms
  • 内存:3588kb
  • [2023-05-26 21:06:21]
  • 提交

answer

#include <stdio.h>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T power(T base,T index,T mod){return((index<=1)?(index?base:1):(power(base*base%mod,index>>1,mod)*power(base,index&1,mod)))%mod;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(!b)return y=0,x=1,a;T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}
template<const ullt p=998244353>
class mod_ullt
{
    private:
        ullt v;
        ullt chg(ullt w){return(w<p)?w:w-p;}
        mod_ullt _chg(ullt w){mod_ullt ans;ans.v=(w<p)?w:w-p;return ans;}
        voi _print(ullt v){if(v>=10)_print(v/10);putchar('0'+v%10);}
    public:
        mod_ullt():v(0){}
        mod_ullt(ullt v):v(v%p){}
        bol empty(){return!v;}
        ullt val(){return v;}
        bol friend operator<(mod_ullt a,mod_ullt b){return a.v<b.v;}
        bol friend operator>(mod_ullt a,mod_ullt b){return a.v>b.v;}
        bol friend operator<=(mod_ullt a,mod_ullt b){return a.v<=b.v;}
        bol friend operator>=(mod_ullt a,mod_ullt b){return a.v>=b.v;}
        bol friend operator==(mod_ullt a,mod_ullt b){return a.v==b.v;}
        bol friend operator!=(mod_ullt a,mod_ullt b){return a.v!=b.v;}
        mod_ullt friend operator+(mod_ullt a,mod_ullt b){return a._chg(a.v+b.v);}
        mod_ullt friend operator-(mod_ullt a,mod_ullt b){return a._chg(a.v+a.chg(p-b.v));}
        mod_ullt friend operator*(mod_ullt a,mod_ullt b){return a.v*b.v;}
        mod_ullt friend operator/(mod_ullt a,mod_ullt b){return b._power(p-2)*a.v;}
        mod_ullt friend operator-(mod_ullt a){return a._chg(p-a.v);}
        mod_ullt sqrt()
        {
            if(power(v,(p-1)>>1,p)!=1)return 0;
            mod_ullt b=1;do b++;while(b._power((p-1)>>1)==1);
            ullt t=p-1,s=0,k=1;while(!(t&1))s++,t>>=1;
            mod_ullt x=_power((t+1)>>1),e=_power(t);
            while(k<s)
            {
                if(e._power(1llu<<(s-k-1))!=1)x*=b._power((1llu<<(k-1))*t);
                e=_power(p-2)*x*x,k++;
            }
            return _min(x,-x),x;
        }
        mod_ullt inv(){return _power(p-2);}
        mod_ullt _power(ullt index){mod_ullt ans(1),w(v);while(index){if(index&1)ans*=w;w*=w,index>>=1;}return ans;}
        voi read(){v=0;chr c;do c=getchar();while(c>'9'||c<'0');do v=(c-'0'+v*10)%p,c=getchar();while(c>='0'&&c<='9');v%=p;}
        voi print(){_print(v);}
        voi println(){_print(v),putchar('\n');}
        mod_ullt operator++(int){mod_ullt ans=*this;return v=chg(v+1),ans;}
    public:
        ullt&operator()(){return v;}
        mod_ullt&operator+=(mod_ullt b){return*this=_chg(v+b.v);}
        mod_ullt&operator-=(mod_ullt b){return*this=_chg(v+chg(p-b.v));}
        mod_ullt&operator*=(mod_ullt b){return*this=v*b.v;}
        mod_ullt&operator/=(mod_ullt b){return*this=b._power(p-2)*v;}
        mod_ullt&operator++(){return v=chg(v+1),*this;}
};
const ullt Mod=1000000007;
typedef mod_ullt<Mod>modint;
modint A[513][513];
int main()
{
    uint n;modint ans(0);scanf("%u",&n);
    while(n--)
    {
        uint v;scanf("%u",&v);
        uint First=v&511,Second=v>>9;
        modint now(0);
        for(uint i=0;i<512;i++)now+=A[First][i|=Second];
        ans+=now++;
        for(uint i=First;~i;i--)A[i&=First][Second]+=now;
    }
    ans.println();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 3ms
memory: 3520kb

input:

9
10
12
2
4
5
6
3
1
7

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 5
Accepted
time: 3ms
memory: 3444kb

input:

9
11
7
2
12
6
10
1
8
9

output:

11

result:

ok 1 number(s): "11"

Test #3:

score: 5
Accepted
time: 3ms
memory: 3452kb

input:

17
13
4
5
17
8
6
10
11
19
1
16
15
20
18
7
3
9

output:

21

result:

ok 1 number(s): "21"

Test #4:

score: 5
Accepted
time: 3ms
memory: 3364kb

input:

17
5
9
3
12
17
14
2
13
20
15
8
1
19
18
7
10
4

output:

25

result:

ok 1 number(s): "25"

Test #5:

score: 5
Accepted
time: 5ms
memory: 3356kb

input:

1911
3082
2173
2002
948
31
3132
394
1319
2245
3638
2283
3575
2105
673
3879
2094
487
547
3136
2010
726
1881
2219
1405
2216
2485
909
138
2788
3839
379
2888
2422
3861
1548
2765
2286
2031
762
3405
3363
3834
2552
2255
2158
3005
2597
3567
2964
1945
832
2732
2867
1729
3888
3471
1
1334
568
1341
2828
3223
24...

output:

704770

result:

ok 1 number(s): "704770"

Test #6:

score: 5
Accepted
time: 5ms
memory: 3384kb

input:

1911
3580
2819
2213
1742
2397
2088
1950
1777
2296
56
1606
2987
3012
712
474
188
894
1439
3642
3896
3953
1158
272
2523
1379
3408
984
3517
3317
985
2697
2192
79
2378
1235
3275
2837
249
3611
1548
1818
3433
1436
2571
385
361
1888
2172
1866
2542
2861
327
3393
2510
669
1088
2823
843
576
3352
3303
2
2943
1...

output:

557002

result:

ok 1 number(s): "557002"

Test #7:

score: 5
Accepted
time: 5ms
memory: 3400kb

input:

1911
577
3076
1041
3574
1307
3239
3235
1174
1581
3012
2911
910
2242
590
2383
123
1997
3980
2871
1049
1127
1569
3375
1193
2799
1113
2710
657
1414
2763
2764
1358
1340
58
302
2335
3015
772
3713
1808
3732
3531
1405
2467
3255
640
19
1138
2949
2372
3797
3548
2198
3603
3510
1507
1701
1537
2145
2953
71
425
...

output:

740269

result:

ok 1 number(s): "740269"

Test #8:

score: 5
Accepted
time: 4ms
memory: 3440kb

input:

1911
2425
3616
2500
2743
364
1444
1988
3972
2418
166
2590
2382
1916
2817
1580
3634
2281
3259
1465
1720
3499
661
1799
466
1359
2984
926
3661
1214
3671
1543
3369
2570
3482
1394
1957
452
2451
3969
69
1639
2008
3138
1039
1454
2100
2413
3157
348
1263
242
3083
2694
3907
2079
3622
3797
1497
3031
2518
93
65...

output:

432697

result:

ok 1 number(s): "432697"

Test #9:

score: 5
Accepted
time: 5ms
memory: 3364kb

input:

2017
218488
42146
96090
102449
15778
35101
229920
73206
112761
175413
231110
89889
227034
226135
69566
153940
218457
49578
25977
90447
177174
65832
223330
154455
180921
201160
8206
41483
209863
137022
147690
59067
53067
21207
114952
15017
72124
61154
196588
8669
66411
146274
199945
7208
11073
172639...

output:

13485

result:

ok 1 number(s): "13485"

Test #10:

score: 5
Accepted
time: 5ms
memory: 3500kb

input:

2017
58546
180201
33517
180306
41829
69393
210231
101666
83924
107960
136142
98214
4082
111929
210895
207073
178036
77822
32162
38249
178215
114967
220451
60485
53001
199469
209842
38166
39473
155065
13334
127632
232783
196767
149134
134986
159119
55559
70565
26664
2486
162103
33658
76508
33460
2003...

output:

14904

result:

ok 1 number(s): "14904"

Test #11:

score: 5
Accepted
time: 4ms
memory: 3356kb

input:

2017
134932
111024
158301
75899
138543
199027
225859
166431
52154
17759
65165
153873
10946
6522
131520
19880
166779
146246
89021
29060
137393
220146
16277
23931
139244
224049
133320
217458
82823
2817
58721
25540
121394
55304
191991
127668
44301
69687
120542
37875
140002
45120
1809
224985
206618
1227...

output:

17461

result:

ok 1 number(s): "17461"

Test #12:

score: 5
Accepted
time: 4ms
memory: 3500kb

input:

2017
4701
39411
149987
70796
209030
179630
42614
173569
37981
99957
31464
21714
7280
224136
72756
84994
133276
181984
225241
164622
220405
16597
225326
136841
178121
26357
61695
213541
99711
217489
41531
21745
49009
189279
45861
134952
109193
229171
222541
52575
24760
95790
148605
36095
66769
116137...

output:

20791

result:

ok 1 number(s): "20791"

Test #13:

score: 5
Accepted
time: 4ms
memory: 3488kb

input:

2017
151295
185649
33154
61834
40666
81266
162689
11623
158620
133790
177744
1157
80979
86094
70584
186428
88732
108761
1500
104902
82475
138087
200586
62572
111550
168497
63324
73505
129108
56603
169535
144304
190548
138531
152071
168001
34716
188228
789
66086
49592
47818
205093
184168
139610
95124...

output:

13689

result:

ok 1 number(s): "13689"

Test #14:

score: 5
Accepted
time: 5ms
memory: 3444kb

input:

2017
15171
129020
170855
112061
206378
38173
182241
44732
112693
167407
14635
106857
182529
231249
207147
53300
66170
95076
158721
110249
54178
57249
185184
76284
206490
10836
130281
174822
12189
54741
24931
154640
36156
38813
125811
86557
217820
110909
26703
223518
94039
168755
66544
171619
99162
5...

output:

11323

result:

ok 1 number(s): "11323"

Test #15:

score: 5
Accepted
time: 46ms
memory: 3456kb

input:

100084
96775
146227
118981
114973
155636
61361
52797
135727
100014
79458
156871
103337
29900
199714
230568
94576
75542
212817
209761
88670
231950
29049
39739
116643
64652
38747
205150
88562
100854
98968
44756
203240
48724
54787
21632
84323
144483
62709
28086
22188
188048
71555
12543
23317
28827
1391...

output:

803835892

result:

ok 1 number(s): "803835892"

Test #16:

score: 5
Accepted
time: 48ms
memory: 3444kb

input:

100084
139251
60142
212660
92363
158267
160993
152491
56810
53129
130925
57394
6149
6890
24040
75331
215334
156913
183486
154254
122230
218647
30542
3586
171680
123474
79254
226166
67001
107547
213092
162489
148459
194026
123261
47316
169632
7591
218956
106070
22672
131513
35898
140366
148068
177953...

output:

721038477

result:

ok 1 number(s): "721038477"

Test #17:

score: 5
Accepted
time: 51ms
memory: 3380kb

input:

100084
22285
149931
11500
153224
30178
163119
143862
150352
124529
621
133063
200406
16669
192435
80930
2140
227212
195940
160396
80486
173240
98023
201478
168471
151466
37413
39155
139906
23157
86686
25929
193301
171733
149512
70575
419
66441
151079
38113
20795
17866
137677
59472
191738
185583
1129...

output:

644845043

result:

ok 1 number(s): "644845043"

Test #18:

score: 5
Accepted
time: 97ms
memory: 3520kb

input:

211985
56745
85888
203224
149508
196917
19806
94439
168072
115773
192410
186668
14937
30665
203706
92787
9902
225180
34799
226899
194570
113245
39343
109015
20416
27096
194910
33879
30845
28540
188961
77789
55655
201080
75103
13926
184282
13956
140977
77233
41733
68819
185566
123481
224338
222106
52...

output:

355662008

result:

ok 1 number(s): "355662008"

Test #19:

score: 5
Accepted
time: 94ms
memory: 3352kb

input:

211985
17372
3705
120938
11738
191475
149356
210407
31291
23060
212571
125053
3610
134473
109284
183750
37338
161312
233161
8010
126517
123679
203406
145432
19862
37462
88050
107637
228310
15475
143790
163127
204766
198240
108908
150992
67252
194118
85988
219394
69937
214818
174585
97056
198060
2878...

output:

435408882

result:

ok 1 number(s): "435408882"

Test #20:

score: 5
Accepted
time: 104ms
memory: 3588kb

input:

211985
50512
91546
110194
112869
158611
177161
168794
27149
91398
174332
95167
14897
230526
196900
118434
103876
171304
145254
217175
120599
121396
128677
99045
185219
43268
1193
51909
111058
152412
194840
72974
86279
147516
186841
17162
39745
20603
117064
179455
146597
21013
152014
204298
223045
18...

output:

474235485

result:

ok 1 number(s): "474235485"

Extra Test:

score: 0
Extra Test Passed