QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383386#2073. Knowledge-Oriented Problemchenxinyang2006AC ✓540ms8748kbC++147.5kb2024-04-09 12:16:382024-04-09 12:16:39

Judging History

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

  • [2024-04-09 12:16:39]
  • 评测
  • 测评结果:AC
  • 用时:540ms
  • 内存:8748kb
  • [2024-04-09 12:16:38]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
    if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
    if(x > y) x = y;
}

inline int popcnt(int x){
    return __builtin_popcount(x);
}

inline int ctz(int x){
    return __builtin_ctz(x);
}

template <int P>
class mod_int
{
    using Z = mod_int;

private:
    static int mo(int x) { return x < 0 ? x + P : x; }

public:
    int x;
    int val() const { return x; }
    mod_int() : x(0) {}
    template <class T>
    mod_int(const T &x_) : x(x_ >= 0 && x_ < P ? static_cast<int>(x_) : mo(static_cast<int>(x_ % P))) {}
    bool operator==(const Z &rhs) const { return x == rhs.x; }
    bool operator!=(const Z &rhs) const { return x != rhs.x; }
    Z operator-() const { return Z(x ? P - x : 0); }
    Z pow(long long k) const
    {
        Z res = 1, t = *this;
        while (k)
        {
            if (k & 1)
                res *= t;
            if (k >>= 1)
                t *= t;
        }
        return res;
    }
    Z &operator++()
    {
        x < P - 1 ? ++x : x = 0;
        return *this;
    }
    Z &operator--()
    {
        x ? --x : x = P - 1;
        return *this;
    }
    Z operator++(int)
    {
        Z ret = x;
        x < P - 1 ? ++x : x = 0;
        return ret;
    }
    Z operator--(int)
    {
        Z ret = x;
        x ? --x : x = P - 1;
        return ret;
    }
    Z inv() const { return pow(P - 2); }
    Z &operator+=(const Z &rhs)
    {
        (x += rhs.x) >= P && (x -= P);
        return *this;
    }
    Z &operator-=(const Z &rhs)
    {
        (x -= rhs.x) < 0 && (x += P);
        return *this;
    }
    Z operator-()
    {
        return -x;
    }
    Z &operator*=(const Z &rhs)
    {
        x = 1ULL * x * rhs.x % P;
        return *this;
    }
    Z &operator/=(const Z &rhs) { return *this *= rhs.inv(); }
#define setO(T, o)                                  \
    friend T operator o(const Z &lhs, const Z &rhs) \
    {                                               \
        Z res = lhs;                                \
        return res o## = rhs;                       \
    }
    setO(Z, +) setO(Z, -) setO(Z, *) setO(Z, /)
#undef setO
    
    friend istream& operator>>(istream& is, mod_int& x)
    {
        long long tmp;
        is >> tmp;
        x = tmp;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mod_int& x)
    {
        os << x.val();
        return os;
    }
};

using Z = mod_int<mod>;
Z power(Z p,ll k){
    Z ans = 1;
    while(k){
        if(k % 2 == 1) ans *= p;
        p *= p;
        k /= 2;
    }
    return ans;
}

struct poly{
    vector <Z> a;
    poly(int sz):a(sz){}
    poly(){}
    poly(vector<Z>b){a=b;}
};
poly operator +(poly p,poly q){
    if(SZ(p.a) < SZ(q.a)) swap(p,q);
    rep(i,0,SZ(q.a) - 1) p.a[i] += q.a[i];
    return p;
}

poly operator *(poly p,poly q){
    int n = SZ(p.a) - 1,m = SZ(q.a) - 1;
    if(n < 0 || m < 0) return poly(0);
    poly ret(n + m + 1);
    rep(i,0,n){
        rep(j,0,m) ret.a[i + j] += p.a[i] * q.a[j];
    } 
    return ret;
}

poly operator %(poly p,poly q){
    int n = SZ(p.a) - 1,m = SZ(q.a) - 1;
    while(m >= 0 && q.a[m].val() == 0) m--;
    assert(m >= 0);

    Z iv = Z(1) / q.a[m],rr;
    per(i,n,m){
        rr = p.a[i] * iv;
        rep(k,0,m) p.a[i - k] -= rr * q.a[m - k];
    }
    p.a.resize(m);
    return p;
}

void divxk(poly &p,int k){
    int deg = SZ(p.a) - 1;
    while(deg >= 0 && p.a[deg].val() == 0) deg--;
    if(deg < k){
        p.a = vector<Z>({0});
        return;
    }
    rep(i,0,deg - k) p.a[i] = p.a[i + k];
    p.a.resize(deg - k + 1);
}

void prt(poly &p){
    int n = SZ(p.a) - 1;
    printf("(");
    rep(i,0,n) printf("%d ",p.a[i].val());
    printf(")");
}

poly Fmod;
struct Matrix{
    poly v[2][2];
};
Matrix operator *(Matrix p,Matrix q){
/*    printf("Matrix multiply\n");
    rep(i,0,1){
        rep(j,0,1){
            prt(p.v[i][j]);
            printf(" ");
        }
        printf("\n");
    }
    rep(i,0,1){
        rep(j,0,1){
            prt(q.v[i][j]);
            printf(" ");
        }
        printf("\n");
    }*/
    Matrix ans;
    rep(i,0,1){
        rep(j,0,1){
            rep(k,0,1) ans.v[i][j] = ans.v[i][j] + p.v[i][k] * q.v[k][j];
        }
    }
/*    rep(i,0,1){
        rep(j,0,1){
            prt(ans.v[i][j]);
            printf(" ");
        }
        printf("\n");
    }  */
    rep(i,0,1){
        rep(j,0,1) ans.v[i][j] = ans.v[i][j] % Fmod;
    }
/*    rep(i,0,1){
        rep(j,0,1){
            prt(ans.v[i][j]);
            printf(" ");
        }
        printf("\n");
    }  */
    return ans;
}

Matrix power(Matrix p,ll K){
    Matrix ret;
    rep(i,0,1) ret.v[i][i].a.eb(1);
    while(K){
        if(K % 2 == 1) ret = ret * p;
        p = p * p;
        K /= 2;
    }
    return ret;
}

Z res(poly p,poly q){
    int n = SZ(p.a) - 1,m = SZ(q.a) - 1;
    if(!n || !m) return power(p.a[n],m) * power(q.a[m],n);

    if(n > m){
        if(n * m % 2) return -res(q,p);
        return res(q,p);
    }
    poly r = q % p;
    return res(p,r) * power(p.a[n],SZ(q.a) - SZ(r.a));
}

int n,m;
ll K;
Z M[505][505];

Z dp[505][505];
poly Char(){
    rep(i,2,n){
        int pos = -1;
        rep(j,i,n) if(M[j][i - 1].val()) pos = j;
        if(pos == -1) continue;

        rep(k,1,n) swap(M[i][k],M[pos][k]);
        rep(k,1,n) swap(M[k][i],M[k][pos]);

        rep(j,i + 1,n){
            Z rr = M[j][i - 1] / M[i][i - 1];
            rep(k,1,n) M[j][k] -= M[i][k] * rr;
            rep(k,1,n) M[k][i] += M[k][j] * rr; 
        }
    }

    dp[0][0] = 1;
    rep(i,1,n){
        rep(k,1,i) dp[i][k] += dp[i - 1][k - 1];
        rep(k,0,i - 1) dp[i][k] -= M[i][i] * dp[i - 1][k];

        Z prd = 1;
        per(j,i,2){
            prd *= M[j][j - 1];
            rep(k,0,j - 2) dp[i][k] -= prd * M[j - 1][i] * dp[j - 2][k];
        }
    }    
    poly ret(n + 1);
    rep(i,0,n) ret.a[i] = dp[n][i];
    return ret;
}

int main(){
//    freopen("test.in","r",stdin);
    scanf("%d%d%lld",&n,&m,&K);
    rep(i,1,m){
        int u,v;
        scanf("%d%d",&u,&v);
        M[u][u]++;M[v][v]++;M[u][v]--;M[v][u]--;
    }
    poly F = Char();
    rep(i,0,n) if(i % 2 != n % 2) F.a[i] *= -1;
//    rep(i,0,n) printf("%d ",F.a[i].val());
//    printf("\n");
    Z answer = F.a[1] / n;
    Fmod = F;
    Matrix st,nxt;
    st.v[0][0].a.eb(1);
    st.v[0][1].a.eb(-1);st.v[0][1].a.eb(1);

    nxt.v[0][1].a.eb(-1);
    nxt.v[1][0].a.eb(1);
    nxt.v[1][1].a.eb(-2);nxt.v[1][1].a.eb(1);

    st = st * power(nxt,K - 1);
    poly G = st.v[0][0] + st.v[0][1];
    divxk(F,1);divxk(G,1);
/*    rep(i,0,SZ(G.a) - 1) printf("%d ",G.a[i].val());
    printf("\n");
    rep(i,0,SZ(F.a) - 1) printf("%d ",F.a[i].val());
    printf("\n");*/
    answer *= res(F,G);
    if(n % 2 == 0 && K % 2 == 0) answer *= -1;
    printf("%d\n",answer.val());
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6036kb

input:

5 6 2
3 2
5 1
3 4
2 4
5 3
1 3

output:

4725

result:

ok single line: '4725'

Test #2:

score: 0
Accepted
time: 1ms
memory: 6040kb

input:

2 1 200
1 2

output:

272581704

result:

ok single line: '272581704'

Test #3:

score: 0
Accepted
time: 1ms
memory: 6080kb

input:

5 10 1000000000000000000
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

output:

569698435

result:

ok single line: '569698435'

Test #4:

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

input:

500 62366 1000000000000000000
1 4
1 7
1 8
1 11
1 13
1 15
1 18
1 20
1 21
1 22
1 23
1 24
1 28
1 29
1 30
1 32
1 33
1 34
1 36
1 37
1 40
1 41
1 43
1 44
1 45
1 46
1 50
1 51
1 52
1 53
1 55
1 57
1 59
1 61
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 75
1 76
1 80
1 81
1 83
1 84
1 85
1 87
1 88
1 9...

output:

822784524

result:

ok single line: '822784524'

Test #5:

score: 0
Accepted
time: 486ms
memory: 8704kb

input:

500 100898 284223895668947515
41 491
140 336
214 284
354 207
38 287
283 326
349 327
238 338
426 304
296 19
322 241
392 414
84 119
400 225
494 243
26 17
367 487
407 330
314 123
55 149
74 386
463 313
463 121
170 313
380 153
421 368
408 362
131 307
129 461
155 141
74 62
308 347
332 218
193 232
40 337
3...

output:

363853035

result:

ok single line: '363853035'

Test #6:

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

input:

500 21757 704623353451185485
249 114
37 343
401 497
357 341
421 295
438 275
205 341
5 486
84 411
311 277
292 279
291 258
361 290
442 179
337 467
373 397
50 444
422 374
182 20
343 336
142 283
111 251
216 158
37 249
332 443
411 70
337 238
95 290
293 84
388 34
195 44
415 389
399 50
184 217
39 30
46 414...

output:

468612490

result:

ok single line: '468612490'

Test #7:

score: 0
Accepted
time: 517ms
memory: 8736kb

input:

500 123868 711982048430368923
209 397
279 238
288 362
240 77
355 195
103 113
13 262
187 485
494 46
329 257
445 101
22 136
158 202
259 75
375 196
490 155
437 295
497 304
95 212
47 297
58 50
254 169
69 490
311 460
150 30
404 193
377 299
301 261
290 256
60 356
397 41
110 175
423 468
288 243
340 308
422...

output:

573623187

result:

ok single line: '573623187'

Test #8:

score: 0
Accepted
time: 505ms
memory: 8532kb

input:

500 110222 324772969324445934
109 110
62 133
406 25
195 453
251 96
65 465
172 344
189 222
2 92
8 271
180 33
345 85
375 154
268 447
358 203
406 225
331 468
295 337
376 28
159 80
455 248
17 409
219 341
352 166
61 137
273 412
203 71
78 56
79 27
443 94
152 370
86 87
332 118
67 240
300 65
409 237
279 120...

output:

590859163

result:

ok single line: '590859163'

Test #9:

score: 0
Accepted
time: 492ms
memory: 8444kb

input:

500 46647 402541440207040649
279 71
67 395
238 101
122 333
436 499
305 280
49 317
492 61
133 86
111 289
35 169
51 6
62 412
290 247
32 256
371 253
169 465
62 279
141 36
200 126
378 290
165 452
378 357
471 252
206 382
329 199
478 477
301 74
49 163
242 268
381 478
111 488
479 23
213 166
478 264
451 156...

output:

849963069

result:

ok single line: '849963069'

Test #10:

score: 0
Accepted
time: 499ms
memory: 8472kb

input:

500 117616 173056698009410794
15 360
263 142
172 109
167 215
491 472
38 264
410 127
161 335
281 426
34 291
67 261
186 334
255 145
205 140
488 210
413 372
141 190
375 478
369 368
111 323
116 38
19 285
15 134
171 346
438 147
467 317
224 227
398 138
430 25
213 304
419 421
380 476
214 218
438 368
452 43...

output:

978447932

result:

ok single line: '978447932'

Test #11:

score: 0
Accepted
time: 506ms
memory: 8444kb

input:

500 122853 354656392050927798
376 345
149 297
480 172
366 464
189 193
351 384
133 95
424 114
49 180
427 467
497 347
26 196
242 182
201 317
15 224
283 326
473 32
5 106
384 304
307 227
309 403
201 91
151 345
315 17
122 298
79 87
299 164
93 487
415 187
137 297
211 19
288 184
423 218
240 50
410 21
391 2...

output:

739721536

result:

ok single line: '739721536'

Test #12:

score: 0
Accepted
time: 507ms
memory: 8452kb

input:

500 63706 962986507492751057
135 101
11 424
404 391
359 178
256 441
183 328
66 458
245 63
347 370
70 123
438 225
488 86
144 231
46 498
370 461
176 228
160 137
180 453
408 186
201 4
18 392
464 288
322 120
51 474
51 342
69 182
291 379
262 437
71 306
227 383
362 460
152 113
126 281
154 33
13 403
229 49...

output:

724935286

result:

ok single line: '724935286'

Test #13:

score: 0
Accepted
time: 488ms
memory: 8472kb

input:

500 67526 242702800740677237
119 72
234 467
222 139
99 461
132 152
286 59
182 142
325 136
277 55
291 152
53 134
44 99
322 257
206 205
227 495
390 302
147 354
136 330
252 295
82 56
245 384
79 102
177 104
226 402
28 330
391 37
445 425
471 339
58 251
248 325
252 275
34 405
156 468
158 265
248 466
476 4...

output:

151188441

result:

ok single line: '151188441'

Test #14:

score: 0
Accepted
time: 487ms
memory: 8404kb

input:

500 67144 533366025681513241
345 47
413 386
30 162
187 384
418 257
91 412
345 61
457 400
38 193
191 222
158 304
368 10
199 346
369 216
182 438
119 177
493 66
151 59
187 388
320 37
476 283
45 358
244 251
292 402
458 140
365 346
2 302
374 103
398 368
193 416
238 427
485 97
148 206
51 466
283 227
357 3...

output:

152487514

result:

ok single line: '152487514'

Test #15:

score: 0
Accepted
time: 500ms
memory: 8540kb

input:

500 41919 207512139809871566
92 213
42 429
235 474
177 438
320 88
46 370
149 195
475 288
377 321
226 320
116 12
488 230
427 291
76 369
369 314
378 446
424 106
7 229
372 39
328 274
454 60
342 236
72 162
464 485
259 310
340 167
125 226
438 328
94 363
16 27
197 451
370 63
397 114
443 49
291 174
430 46
...

output:

956606609

result:

ok single line: '956606609'

Test #16:

score: 0
Accepted
time: 460ms
memory: 8472kb

input:

500 117447 4246580732208067
440 65
254 92
144 258
152 5
18 104
410 447
449 168
161 194
80 41
452 472
440 158
287 179
57 483
224 157
418 291
438 461
269 250
317 396
316 154
15 6
187 73
326 366
191 261
136 68
188 32
201 19
314 356
55 167
475 236
61 413
445 172
297 77
5 238
96 34
246 284
443 270
206 48...

output:

221526357

result:

ok single line: '221526357'

Test #17:

score: 0
Accepted
time: 486ms
memory: 8472kb

input:

500 25978 953453753321133570
275 133
167 8
365 127
292 245
186 305
102 101
13 327
480 429
10 369
369 161
160 304
60 357
144 313
51 267
466 237
418 261
168 299
437 143
246 175
167 250
24 187
278 239
214 351
295 71
53 213
380 192
69 461
110 174
408 253
248 381
247 415
356 35
195 309
164 459
448 428
47...

output:

584641887

result:

ok single line: '584641887'

Test #18:

score: 0
Accepted
time: 533ms
memory: 8748kb

input:

500 63502 863851591073511160
138 230
256 82
388 114
341 400
214 92
472 268
152 415
86 8
288 147
248 102
228 210
447 477
245 321
418 426
486 60
343 349
450 102
138 208
323 242
483 56
119 500
253 211
308 185
56 216
231 18
279 230
346 32
325 165
187 394
123 401
291 443
367 256
471 121
225 172
316 129
4...

output:

799372014

result:

ok single line: '799372014'

Test #19:

score: 0
Accepted
time: 528ms
memory: 8448kb

input:

500 81854 471469997343615763
224 393
339 65
151 365
37 467
409 289
470 459
474 309
228 478
462 31
288 470
76 447
372 320
219 289
378 186
121 77
265 316
220 64
299 29
158 157
52 276
435 266
190 344
173 276
258 470
36 265
466 371
348 372
433 249
285 21
199 209
169 87
26 100
133 176
261 103
415 468
364...

output:

870345053

result:

ok single line: '870345053'

Test #20:

score: 0
Accepted
time: 504ms
memory: 8404kb

input:

500 49336 854776547738210439
18 1
326 233
447 4
452 373
35 194
179 174
253 197
189 316
402 358
59 120
172 214
418 8
305 390
193 335
24 403
80 355
459 357
143 44
372 456
27 112
443 209
293 255
368 258
256 162
356 79
39 187
70 247
197 417
493 317
459 287
178 154
325 127
418 107
43 393
87 472
462 240
1...

output:

483230620

result:

ok single line: '483230620'

Test #21:

score: 0
Accepted
time: 512ms
memory: 8472kb

input:

500 92358 644771527880957176
481 451
425 440
286 426
293 323
169 401
455 322
114 193
494 50
317 216
192 295
124 217
364 439
427 490
152 272
274 471
190 277
54 403
18 217
66 60
142 8
24 41
493 13
329 165
129 379
419 120
250 141
300 100
107 476
317 383
138 215
266 123
148 13
107 104
288 193
89 90
405 ...

output:

870166222

result:

ok single line: '870166222'

Test #22:

score: 0
Accepted
time: 519ms
memory: 8400kb

input:

500 90725 385576009722030966
82 342
465 299
150 203
405 145
50 243
301 195
492 70
222 197
170 336
184 87
253 162
426 266
167 385
174 138
3 416
106 25
280 349
73 315
31 285
77 457
203 125
498 187
479 465
298 409
218 423
77 148
471 198
446 249
28 273
198 467
209 470
127 112
232 128
294 92
375 300
65 1...

output:

60211306

result:

ok single line: '60211306'

Test #23:

score: 0
Accepted
time: 500ms
memory: 8456kb

input:

500 72346 421261822986340506
284 13
377 394
89 175
489 328
81 39
151 203
231 310
283 165
406 395
346 321
150 480
276 288
399 96
16 174
167 175
124 29
246 392
416 475
370 154
384 194
318 204
371 390
62 436
433 404
317 171
417 83
465 185
421 489
281 376
446 475
404 16
460 312
196 20
348 374
49 352
194...

output:

949936006

result:

ok single line: '949936006'

Test #24:

score: 0
Accepted
time: 499ms
memory: 8448kb

input:

500 29171 349409044730175974
322 431
322 495
495 67
206 365
293 139
423 288
213 494
75 330
423 111
113 20
490 248
149 402
290 456
224 264
155 348
285 69
162 157
78 102
182 458
136 392
84 354
190 297
377 245
323 59
389 153
390 344
272 266
454 385
134 180
173 323
348 68
478 397
455 297
157 477
205 387...

output:

359735146

result:

ok single line: '359735146'

Test #25:

score: 0
Accepted
time: 316ms
memory: 8544kb

input:

500 124750 361734026065137245
64 15
138 415
182 167
460 399
213 467
32 151
220 494
242 321
342 158
313 469
28 446
312 221
320 176
431 85
410 297
218 343
481 86
234 457
139 50
200 101
166 182
116 371
342 114
422 107
111 133
463 43
366 495
399 150
467 126
264 300
154 377
467 286
154 138
464 243
71 262...

output:

604587986

result:

ok single line: '604587986'

Test #26:

score: 0
Accepted
time: 303ms
memory: 8476kb

input:

500 0 101300732058141740

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 0ms
memory: 5780kb

input:

1 0 143769923103509429

output:

1

result:

ok single line: '1'

Test #28:

score: 0
Accepted
time: 1ms
memory: 5808kb

input:

2 0 885757731048851648

output:

0

result:

ok single line: '0'

Test #29:

score: 0
Accepted
time: 1ms
memory: 6068kb

input:

2 1 886583974226935072
2 1

output:

600161775

result:

ok single line: '600161775'

Test #30:

score: 0
Accepted
time: 502ms
memory: 8476kb

input:

500 500 628435535440884339
472 471
283 284
483 499
117 450
356 6
333 334
497 498
74 73
376 495
457 458
313 90
183 184
327 309
121 323
388 387
489 65
216 215
247 248
50 49
382 220
402 228
128 127
461 462
243 131
363 56
17 231
358 357
168 167
392 28
463 138
109 110
22 35
475 154
186 141
235 236
148 14...

output:

0

result:

ok single line: '0'

Test #31:

score: 0
Accepted
time: 460ms
memory: 8516kb

input:

498 996 207205396094409066
246 244
346 348
335 336
460 232
411 233
330 328
9 7
442 443
461 462
14 263
362 361
134 135
492 174
118 120
104 103
426 424
158 157
5 4
377 378
70 25
278 350
149 150
202 223
399 486
360 359
348 420
166 176
3 2
235 259
39 345
14 437
426 111
199 403
430 478
287 288
369 210
16...

output:

994116447

result:

ok single line: '994116447'

Test #32:

score: 0
Accepted
time: 438ms
memory: 8468kb

input:

500 1500 569847673187348918
328 64
188 186
180 179
434 125
105 106
401 61
188 185
56 320
293 295
89 91
308 251
475 274
170 169
58 419
229 411
372 456
256 253
406 407
500 498
137 97
87 123
414 413
376 375
211 219
462 461
140 241
453 455
309 181
73 140
85 88
9 10
436 434
500 35
236 233
231 152
438 481...

output:

560806868

result:

ok single line: '560806868'

Test #33:

score: 0
Accepted
time: 428ms
memory: 8476kb

input:

500 2000 581573135001568625
276 406
482 485
8 10
149 150
21 24
317 316
72 177
447 446
317 308
134 220
30 29
256 257
356 476
176 179
32 33
344 341
434 435
390 353
141 367
137 136
449 3
321 142
365 363
350 348
166 169
489 379
330 328
53 55
147 301
183 369
403 401
236 77
402 404
351 317
165 162
456 459...

output:

558426916

result:

ok single line: '558426916'

Test #34:

score: 0
Accepted
time: 421ms
memory: 8452kb

input:

498 2490 348779769860944754
1 4
302 367
448 450
132 131
222 218
393 392
334 332
442 440
111 114
404 103
323 324
111 109
495 262
444 443
348 344
431 427
3 346
172 460
112 123
354 351
328 329
273 369
468 258
91 85
138 222
436 437
81 84
491 474
22 21
316 317
149 145
399 82
357 460
85 87
131 467
69 439
...

output:

396425759

result:

ok single line: '396425759'

Test #35:

score: 0
Accepted
time: 388ms
memory: 8440kb

input:

497 2982 801742040391126126
189 111
219 223
258 256
319 321
450 437
412 311
345 99
99 105
61 58
13 495
364 360
24 353
123 124
270 273
351 162
410 411
166 165
208 207
178 304
41 306
80 79
233 232
353 354
96 93
426 230
205 207
46 45
230 225
322 320
214 213
30 37
243 239
32 101
478 480
51 36
52 50
336 ...

output:

611397890

result:

ok single line: '611397890'

Test #36:

score: 0
Accepted
time: 398ms
memory: 8412kb

input:

496 3472 753715368855971622
231 151
88 39
430 471
415 412
94 89
177 181
48 41
180 405
201 206
361 364
305 308
407 404
195 196
470 469
283 286
344 337
214 299
320 313
6 207
309 358
251 45
411 210
297 302
452 87
83 435
213 209
308 278
158 256
416 414
391 386
285 287
23 70
126 123
329 330
104 120
93 13...

output:

958319783

result:

ok single line: '958319783'

Test #37:

score: 0
Accepted
time: 367ms
memory: 8400kb

input:

495 3960 619479696698478912
255 253
361 244
60 20
80 77
227 362
390 392
157 46
128 219
329 331
124 23
20 411
356 373
40 290
6 266
130 239
488 56
257 7
296 153
447 114
255 282
118 125
431 425
204 71
21 221
110 345
472 474
214 215
472 490
29 31
439 277
157 38
46 182
100 218
196 195
242 235
220 444
425...

output:

230600496

result:

ok single line: '230600496'

Test #38:

score: 0
Accepted
time: 372ms
memory: 8472kb

input:

500 4500 326159689610738492
31 38
16 117
8 159
162 165
374 335
319 311
327 321
421 11
83 82
223 226
359 8
221 229
118 497
244 248
171 131
344 350
488 48
179 180
165 412
500 200
169 196
80 73
65 62
19 15
305 98
249 49
491 495
201 21
361 363
496 497
209 201
33 301
178 174
367 49
28 37
104 108
248 27
3...

output:

339309828

result:

ok single line: '339309828'

Test #39:

score: 0
Accepted
time: 373ms
memory: 8396kb

input:

495 4950 498837327937767379
275 143
350 342
50 52
186 181
66 472
415 418
249 246
444 212
332 255
195 226
263 262
366 56
214 323
172 169
434 334
181 177
182 269
355 182
410 413
399 405
305 396
392 391
321 320
9 395
364 372
150 39
123 309
242 241
385 375
237 280
450 32
93 99
23 33
463 35
254 262
391 2...

output:

316826163

result:

ok single line: '316826163'

Test #40:

score: 0
Accepted
time: 373ms
memory: 8376kb

input:

492 5412 255858166820806394
381 416
368 232
96 444
180 177
428 430
258 304
461 467
125 130
482 38
283 284
342 339
468 348
146 254
389 394
418 477
265 219
223 41
118 114
437 352
472 152
203 194
132 129
202 200
360 354
379 186
455 48
457 463
37 44
405 402
394 396
400 404
438 444
328 149
273 271
192 18...

output:

912507610

result:

ok single line: '912507610'

Test #41:

score: 0
Accepted
time: 366ms
memory: 8356kb

input:

494 5928 550242775512212348
476 319
358 88
221 416
477 478
284 233
386 281
118 67
222 483
400 392
346 342
295 219
141 138
484 160
317 7
414 437
284 270
312 302
130 123
208 468
472 473
403 396
364 260
137 138
297 299
150 146
403 395
376 377
119 430
358 295
181 51
356 354
434 435
286 494
361 350
148 3...

output:

714085459

result:

ok single line: '714085459'

Test #42:

score: 0
Accepted
time: 350ms
memory: 8636kb

input:

490 6370 886532112655498408
26 15
198 208
177 181
388 379
320 318
14 12
317 309
91 92
131 139
355 354
312 320
61 161
178 305
77 473
303 296
213 47
320 152
203 199
61 121
285 281
375 39
279 489
235 230
324 309
389 335
429 440
95 98
385 390
448 196
397 270
255 258
48 59
489 405
415 420
273 278
174 171...

output:

623144727

result:

ok single line: '623144727'

Test #43:

score: 0
Accepted
time: 348ms
memory: 8424kb

input:

495 6930 199228351458279880
122 133
328 317
303 315
42 33
180 173
412 417
325 245
271 106
204 487
169 171
459 398
37 44
228 212
355 358
108 361
235 226
71 115
167 179
32 37
413 354
311 429
71 74
203 206
88 82
479 266
28 222
136 438
132 124
388 41
401 393
412 70
236 281
210 198
375 30
397 404
490 430...

output:

965591814

result:

ok single line: '965591814'

Test #44:

score: 0
Accepted
time: 324ms
memory: 8408kb

input:

496 7440 9069505453357242
166 407
51 57
372 379
94 351
277 279
34 47
294 291
312 316
478 479
75 62
385 113
399 191
39 46
86 262
462 454
156 416
255 248
424 197
179 188
287 47
61 474
317 413
78 70
395 139
453 449
391 55
473 314
71 425
175 335
203 205
61 74
72 168
123 121
297 198
369 17
350 344
18 29
...

output:

15734494

result:

ok single line: '15734494'

Test #45:

score: 0
Accepted
time: 370ms
memory: 8340kb

input:

493 7888 859200433590886987
300 215
225 232
151 168
486 493
103 110
68 51
487 493
434 426
364 243
66 61
190 201
257 360
411 414
287 289
26 27
254 255
249 334
427 462
345 353
320 311
2 1
446 240
287 407
407 404
54 412
467 178
259 256
6 466
255 253
150 148
206 219
162 159
153 84
12 230
189 173
472 385...

output:

933424068

result:

ok single line: '933424068'

Test #46:

score: 0
Accepted
time: 338ms
memory: 8304kb

input:

486 8262 322586350282747686
414 287
102 98
332 314
132 138
110 125
79 115
411 50
173 266
206 208
110 115
112 147
337 283
442 371
123 409
80 458
293 290
286 395
441 439
124 410
426 423
435 346
418 419
332 421
44 206
414 406
423 415
284 484
146 159
39 291
83 406
417 94
194 157
4 203
160 151
168 167
31...

output:

667191442

result:

ok single line: '667191442'

Test #47:

score: 0
Accepted
time: 323ms
memory: 8392kb

input:

494 8892 867940116716519779
84 447
297 302
403 411
20 34
24 3
328 330
63 118
243 126
441 326
358 345
16 358
94 91
205 54
225 492
85 95
421 381
346 424
272 404
487 390
381 399
319 112
279 374
383 366
347 361
400 343
216 226
222 228
245 235
236 242
172 419
411 404
227 217
3 327
126 131
351 349
119 103...

output:

268526520

result:

ok single line: '268526520'

Test #48:

score: 0
Accepted
time: 313ms
memory: 6152kb

input:

500 0 58141740406992180

output:

0

result:

ok single line: '0'

Test #49:

score: 0
Accepted
time: 317ms
memory: 8436kb

input:

500 124750 65137245455960715
64 15
138 415
182 167
460 399
213 467
32 151
220 494
242 321
342 158
313 469
28 446
312 221
320 176
431 85
410 297
218 343
481 86
234 457
139 50
200 101
166 182
116 371
342 114
422 107
111 133
463 43
366 495
399 150
467 126
264 300
154 377
467 286
154 138
464 243
71 262
...

output:

198653036

result:

ok single line: '198653036'

Test #50:

score: 0
Accepted
time: 515ms
memory: 8740kb

input:

500 50000 440386086082702581
116 147
64 343
316 435
292 271
178 135
94 341
414 247
343 376
289 394
235 458
396 209
162 175
57 247
192 275
420 240
245 9
309 259
162 344
372 305
273 248
57 66
210 366
323 239
456 96
65 369
465 232
328 347
138 255
397 210
368 396
139 343
267 275
184 126
178 160
361 483
...

output:

536271158

result:

ok single line: '536271158'