QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709561#8408. Obrazy [C]liuziao10 ✓0ms3728kbC++23891b2024-11-04 15:27:352024-11-04 15:27:36

Judging History

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

  • [2024-11-04 15:27:36]
  • 评测
  • 测评结果:10
  • 用时:0ms
  • 内存:3728kb
  • [2024-11-04 15:27:35]
  • 提交

answer

#include <bits/stdc++.h>

#define int int64_t

int h, w, n;
int a[35];

void dickdreamer() {
  std::cin >> h >> w >> n;
  for (int i = 1; i <= n; ++i) std::cin >> a[i];
  if (h % a[1] != 0 || w % a[1] != 0) return void(std::cout << "-1\n");
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    h /= a[i], w /= a[i];
    for (int j = i + 1; j <= n; ++j) a[j] /= a[i];
    a[i] = 1;
    if (i == n) {
      ans += h * w;
    } else {
      ans += h * w - (h / a[i + 1] * a[i + 1]) * (w / a[i + 1] * a[i + 1]);
    }
  }
  std::cout << ans << '\n';
}

int32_t main() {
#ifdef ORZXKR
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
  int T = 1;
  // std::cin >> T;
  while (T--) dickdreamer();
  // std::cerr << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

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

input:

1 1
1
1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

1 1
1
2

output:

-1

result:

ok single line: '-1'

Test #3:

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

input:

2 2
1
1

output:

4

result:

ok single line: '4'

Test #4:

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

input:

2 2
1
2

output:

1

result:

ok single line: '1'

Test #5:

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

input:

8 8
2
2 6

output:

8

result:

ok single line: '8'

Test #6:

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

input:

9 10
3
1 2 8

output:

15

result:

ok single line: '15'

Subtask #2:

score: 1
Accepted

Test #7:

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

input:

50 50
1
1

output:

2500

result:

ok single line: '2500'

Test #8:

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

input:

50 50
1
50

output:

1

result:

ok single line: '1'

Test #9:

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

input:

16 46
4
2 8 32 96

output:

34

result:

ok single line: '34'

Test #10:

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

input:

38 11
5
1 4 20 40 80

output:

148

result:

ok single line: '148'

Test #11:

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

input:

12 50
4
2 6 24 96

output:

22

result:

ok single line: '22'

Test #12:

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

input:

44 37
4
1 4 12 60

output:

71

result:

ok single line: '71'

Test #13:

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

input:

2 10
7
1 2 4 8 16 32 64

output:

5

result:

ok single line: '5'

Test #14:

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

input:

6 12
6
1 2 6 12 36 72

output:

2

result:

ok single line: '2'

Test #15:

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

input:

18 18
6
3 6 12 24 48 96

output:

6

result:

ok single line: '6'

Test #16:

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

input:

45 5
7
1 2 4 8 16 32 64

output:

60

result:

ok single line: '60'

Test #17:

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

input:

10 22
2
2 96

output:

55

result:

ok single line: '55'

Test #18:

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

input:

28 50
2
1 81

output:

1400

result:

ok single line: '1400'

Test #19:

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

input:

50 50
6
1 2 4 8 16 32

output:

55

result:

ok single line: '55'

Test #20:

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

input:

31 31
5
1 2 4 8 16

output:

109

result:

ok single line: '109'

Test #21:

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

input:

33 9
4
3 9 36 72

output:

9

result:

ok single line: '9'

Test #22:

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

input:

50 25
5
1 5 25 50 100

output:

2

result:

ok single line: '2'

Subtask #3:

score: 1
Accepted

Test #23:

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

input:

100 100
1
1

output:

10000

result:

ok single line: '10000'

Test #24:

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

input:

100 100
1
100

output:

1

result:

ok single line: '1'

Test #25:

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

input:

64 80
5
4 8 16 48 192

output:

12

result:

ok single line: '12'

Test #26:

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

input:

44 2
6
1 2 8 24 96 192

output:

22

result:

ok single line: '22'

Test #27:

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

input:

32 20
5
1 3 15 75 150

output:

112

result:

ok single line: '112'

Test #28:

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

input:

38 41
5
1 3 15 75 150

output:

214

result:

ok single line: '214'

Test #29:

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

input:

58 91
8
1 2 4 8 16 32 64 128

output:

157

result:

ok single line: '157'

Test #30:

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

input:

13 2
6
1 2 6 18 54 108

output:

8

result:

ok single line: '8'

Test #31:

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

input:

50 62
7
2 4 8 16 32 64 128

output:

79

result:

ok single line: '79'

Test #32:

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

input:

46 20
6
1 2 6 18 36 108

output:

46

result:

ok single line: '46'

Test #33:

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

input:

72 56
4
2 8 80 160

output:

63

result:

ok single line: '63'

Test #34:

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

input:

52 18
1
1

output:

936

result:

ok single line: '936'

Test #35:

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

input:

100 100
7
1 2 4 8 16 32 64

output:

55

result:

ok single line: '55'

Test #36:

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

input:

63 63
6
1 2 4 8 16 32

output:

234

result:

ok single line: '234'

Test #37:

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

input:

78 96
5
2 16 32 96 192

output:

342

result:

ok single line: '342'

Test #38:

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

input:

60 15
4
3 15 60 120

output:

4

result:

ok single line: '4'

Test #39:

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

input:

60 8
5
4 16 32 96 192

output:

30

result:

ok single line: '30'

Subtask #4:

score: 1
Accepted

Test #40:

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

input:

1000 1000
1
1

output:

1000000

result:

ok single line: '1000000'

Test #41:

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

input:

1000 1000
1
1000

output:

1

result:

ok single line: '1'

Test #42:

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

input:

771 567
7
3 12 48 192 384 768 1536

output:

687

result:

ok single line: '687'

Test #43:

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

input:

514 920
8
1 2 8 16 32 160 800 1600

output:

644

result:

ok single line: '644'

Test #44:

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

input:

919 884
6
3 15 60 240 480 1920

output:

-1

result:

ok single line: '-1'

Test #45:

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

input:

25 674
7
1 4 20 60 180 540 1620

output:

938

result:

ok single line: '938'

Test #46:

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

input:

785 234
11
1 2 4 8 16 32 64 128 256 512 1024

output:

780

result:

ok single line: '780'

Test #47:

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

input:

98 124
9
1 3 9 18 36 72 216 432 1296

output:

505

result:

ok single line: '505'

Test #48:

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

input:

322 460
7
23 46 92 184 368 736 1472

output:

19

result:

ok single line: '19'

Test #49:

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

input:

581 469
6
7 21 63 189 945 1890

output:

257

result:

ok single line: '257'

Test #50:

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

input:

426 324
2
3 1200

output:

15336

result:

ok single line: '15336'

Test #51:

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

input:

828 79
3
1 6 78

output:

942

result:

ok single line: '942'

Test #52:

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

input:

1000 1000
10
1 2 4 8 16 32 64 128 256 512

output:

358

result:

ok single line: '358'

Test #53:

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

input:

511 511
9
1 2 4 8 16 32 64 128 256

output:

2017

result:

ok single line: '2017'

Test #54:

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

input:

684 576
7
3 12 36 72 288 576 1728

output:

25

result:

ok single line: '25'

Test #55:

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

input:

108 822
7
6 18 36 108 324 648 1296

output:

52

result:

ok single line: '52'

Test #56:

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

input:

18 72
5
9 45 225 900 1800

output:

16

result:

ok single line: '16'

Subtask #5:

score: 1
Accepted

Test #57:

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

input:

5000 5000
1
1

output:

25000000

result:

ok single line: '25000000'

Test #58:

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

input:

5000 5000
1
5000

output:

1

result:

ok single line: '1'

Test #59:

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

input:

662 3154
8
1 4 16 80 160 480 1440 5760

output:

8729

result:

ok single line: '8729'

Test #60:

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

input:

435 2814
10
1 3 6 18 54 216 648 1944 3888 7776

output:

1036

result:

ok single line: '1036'

Test #61:

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

input:

2709 3568
7
4 20 80 320 1280 2560 7680

output:

-1

result:

ok single line: '-1'

Test #62:

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

input:

1229 615
9
1 5 10 30 60 240 960 3840 7680

output:

3119

result:

ok single line: '3119'

Test #63:

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

input:

1853 1369
14
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192

output:

4247

result:

ok single line: '4247'

Test #64:

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

input:

688 2608
11
1 3 6 12 24 72 216 648 1296 3888 7776

output:

4777

result:

ok single line: '4777'

Test #65:

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

input:

1092 2379
5
39 195 780 2340 7020

output:

223

result:

ok single line: '223'

Test #66:

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

input:

3069 234
7
9 18 72 216 864 2592 5184

output:

234

result:

ok single line: '234'

Test #67:

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

input:

195 3939
3
13 260 780

output:

4545

result:

ok single line: '4545'

Test #68:

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

input:

3404 3456
2
2 36

output:

26304

result:

ok single line: '26304'

Test #69:

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

input:

5000 5000
13
1 2 4 8 16 32 64 128 256 512 1024 2048 4096

output:

1381

result:

ok single line: '1381'

Test #70:

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

input:

4095 4095
12
1 2 4 8 16 32 64 128 256 512 1024 2048

output:

16344

result:

ok single line: '16344'

Test #71:

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

input:

161 2450
6
7 49 98 588 4704 9408

output:

775

result:

ok single line: '775'

Test #72:

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

input:

2688 3360
7
1 12 96 672 1344 2688 8064

output:

5

result:

ok single line: '5'

Test #73:

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

input:

4316 44
6
4 24 120 360 1080 5400

output:

5604

result:

ok single line: '5604'

Subtask #6:

score: 1
Accepted

Test #74:

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

input:

100000 100000
1
1

output:

10000000000

result:

ok single line: '10000000000'

Test #75:

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

input:

100000 100000
1
100000

output:

1

result:

ok single line: '1'

Test #76:

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

input:

64485 1350
9
15 60 120 600 1800 3600 10800 54000 162000

output:

9633

result:

ok single line: '9633'

Test #77:

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

input:

40264 36318
11
2 10 20 40 200 600 1800 3600 7200 21600 108000

output:

127896

result:

ok single line: '127896'

Test #78:

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

input:

19959 54779
10
12 24 48 144 720 3600 10800 43200 86400 172800

output:

-1

result:

ok single line: '-1'

Test #79:

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

input:

92206 91535
11
1 2 10 50 250 1250 3750 11250 22500 45000 135000

output:

358299

result:

ok single line: '358299'

Test #80:

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

input:

50932 69846
18
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072

output:

68436

result:

ok single line: '68436'

Test #81:

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

input:

62505 73764
14
1 2 4 12 36 108 216 648 1944 3888 7776 15552 46656 139968

output:

116479

result:

ok single line: '116479'

Test #82:

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

input:

22908 35026
7
166 1162 2324 9296 27888 83664 167328

output:

1263

result:

ok single line: '1263'

Test #83:

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

input:

8877 1881
6
33 99 297 3564 60588 121176

output:

413

result:

ok single line: '413'

Test #84:

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

input:

82964 77861
3
7 35 100800

output:

5328676

result:

ok single line: '5328676'

Test #85:

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

input:

13092 33258
3
3 684 8208

output:

970236

result:

ok single line: '970236'

Test #86:

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

input:

100000 100000
17
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536

output:

8398

result:

ok single line: '8398'

Test #87:

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

input:

65535 65535
16
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768

output:

262092

result:

ok single line: '262092'

Test #88:

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

input:

18570 25920
8
30 120 240 720 2880 8640 25920 103680

output:

2850

result:

ok single line: '2850'

Test #89:

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

input:

48375 13373
7
43 129 645 3225 12900 64500 129000

output:

3390

result:

ok single line: '3390'

Test #90:

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

input:

187 20111
10
17 34 102 204 1020 2040 10200 30600 61200 183600

output:

2572

result:

ok single line: '2572'

Subtask #7:

score: 1
Accepted

Test #91:

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

input:

1000000 1000000
1
1

output:

1000000000000

result:

ok single line: '1000000000000'

Test #92:

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

input:

1000000 1000000
1
1000000

output:

1

result:

ok single line: '1'

Test #93:

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

input:

226098 814716
9
53 212 424 1272 6360 19080 95400 381600 1144800

output:

37863

result:

ok single line: '37863'

Test #94:

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

input:

995505 162639
11
3 9 45 180 720 2160 6480 12960 64800 324000 1620000

output:

307859

result:

ok single line: '307859'

Test #95:

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

input:

943198 789062
11
7 21 63 252 756 1512 4536 13608 68040 340200 1360800

output:

-1

result:

ok single line: '-1'

Test #96:

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

input:

705965 82216
11
2 8 32 64 256 1280 6400 19200 96000 288000 1440000

output:

-1

result:

ok single line: '-1'

Test #97:

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

input:

297431 173154
21
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576

output:

481653

result:

ok single line: '481653'

Test #98:

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

input:

577103 752756
19
1 2 4 12 24 72 216 432 864 1728 5184 10368 20736 41472 82944 165888 331776 663552 1327104

output:

1997057

result:

ok single line: '1997057'

Test #99:

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

input:

931728 276528
6
168 1680 18480 240240 720720 1441440

output:

49468

result:

ok single line: '49468'

Test #100:

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

input:

998868 429195
5
39 1209 31434 62868 1948908

output:

86965

result:

ok single line: '86965'

Test #101:

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

input:

37323 505593
3
99 495 2475

output:

14099

result:

ok single line: '14099'

Test #102:

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

input:

786234 749502
3
1 104 416

output:

138208623

result:

ok single line: '138208623'

Test #103:

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

input:

1000000 1000000
20
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288

output:

35323

result:

ok single line: '35323'

Test #104:

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

input:

524287 524287
19
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144

output:

2097091

result:

ok single line: '2097091'

Test #105:

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

input:

678852 604800
10
12 60 180 360 2880 5760 40320 161280 483840 1935360

output:

73027

result:

ok single line: '73027'

Test #106:

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

input:

846720 102816
7
21 126 1512 10584 105840 846720 1693440

output:

3520

result:

ok single line: '3520'

Test #107:

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

input:

915990 665
10
95 285 1140 3420 6840 20520 82080 246240 738720 1477440

output:

16070

result:

ok single line: '16070'

Subtask #8:

score: 1
Accepted

Test #108:

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

input:

10000000 10000000
1
1

output:

100000000000000

result:

ok single line: '100000000000000'

Test #109:

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

input:

10000000 10000000
1
10000000

output:

1

result:

ok single line: '1'

Test #110:

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

input:

9540470 7595250
12
95 475 1425 5700 11400 22800 45600 182400 547200 1641600 4924800 14774400

output:

111852

result:

ok single line: '111852'

Test #111:

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

input:

1152279 9624003
15
3 15 45 90 180 900 1800 9000 27000 54000 108000 324000 972000 2916000 11664000

output:

10345814

result:

ok single line: '10345814'

Test #112:

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

input:

6875240 7161181
13
11 44 220 660 2640 5280 26400 79200 396000 792000 1584000 3168000 12672000

output:

-1

result:

ok single line: '-1'

Test #113:

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

input:

8096335 3201493
13
5 25 125 250 750 1500 7500 15000 75000 150000 600000 3000000 12000000

output:

-1

result:

ok single line: '-1'

Test #114:

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

input:

9975208 5846965
25
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216

output:

14544100

result:

ok single line: '14544100'

Test #115:

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

input:

769455 3642815
18
1 3 9 18 54 162 486 1458 4374 8748 26244 52488 157464 472392 1417176 2834352 8503056 17006112

output:

2249757

result:

ok single line: '2249757'

Test #116:

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

input:

9545500 3757558
5
1123 26952 80856 727704 11643264

output:

98926

result:

ok single line: '98926'

Test #117:

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

input:

2758428 604638
6
27 702 9828 520884 5208840 10417680

output:

1079401

result:

ok single line: '1079401'

Test #118:

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

input:

1431426 252174
4
122 732 54900 109800

output:

128937

result:

ok single line: '128937'

Test #119:

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

input:

5055412 7773812
3
4 5760 63360

output:

3018758122

result:

ok single line: '3018758122'

Test #120:

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

input:

10000000 10000000
24
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608

output:

220384

result:

ok single line: '220384'

Test #121:

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

input:

8388607 8388607
23
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304

output:

33554359

result:

ok single line: '33554359'

Test #122:

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

input:

4207700 5529600
13
100 400 1600 6400 19200 38400 115200 230400 460800 921600 1843200 5529600 11059200

output:

100674

result:

ok single line: '100674'

Test #123:

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

input:

2177280 1383760
13
28 56 168 336 1008 5040 15120 60480 120960 483840 1451520 5806080 11612160

output:

95982

result:

ok single line: '95982'

Test #124:

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

input:

1222 7395356
10
94 564 2256 4512 9024 45120 180480 1082880 3248640 19491840

output:

104922

result:

ok single line: '104922'

Subtask #9:

score: 1
Accepted

Test #125:

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

input:

100000000 100000000
1
1

output:

10000000000000000

result:

ok single line: '10000000000000000'

Test #126:

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

input:

100000000 100000000
1
100000000

output:

1

result:

ok single line: '1'

Test #127:

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

input:

93858048 85468176
11
432 1296 5184 10368 31104 155520 311040 1555200 6220800 31104000 124416000

output:

972727

result:

ok single line: '972727'

Test #128:

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

input:

24502470 78570405
16
3 12 24 72 288 1440 7200 28800 57600 172800 345600 1728000 3456000 17280000 86400000 172800000

output:

82111148

result:

ok single line: '82111148'

Test #129:

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

input:

86079326 29476747
15
13 39 78 312 624 1248 4992 24960 99840 299520 1198080 5990400 23961600 47923200 191692800

output:

-1

result:

ok single line: '-1'

Test #130:

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

input:

28915588 32215896
16
4 16 64 128 256 1280 2560 10240 51200 204800 409600 1228800 6144000 24576000 73728000 147456000

output:

25538227

result:

ok single line: '25538227'

Test #131:

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

input:

66509160 96307908
28
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728

output:

35361744

result:

ok single line: '35361744'

Test #132:

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

input:

67314639 97831179
22
1 3 6 12 36 72 216 432 864 2592 5184 15552 46656 93312 279936 839808 1679616 5038848 15116544 45349632 90699264 181398528

output:

72470628

result:

ok single line: '72470628'

Test #133:

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

input:

15980423 59097189
7
1081 33511 67022 603198 1206396 38604672 193023360

output:

1718681

result:

ok single line: '1718681'

Test #134:

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

input:

55994400 46281480
5
280 15400 908600 79048200 158096400

output:

3511860

result:

ok single line: '3511860'

Test #135:

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

input:

99505796 74861054
4
419 1257 2514000 37710000

output:

190850187

result:

ok single line: '190850187'

Test #136:

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

input:

11029168 9975860
3
4 13918716 97431012

output:

6876589742780

result:

ok single line: '6876589742780'

Test #137:

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

input:

100000000 100000000
27
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864

output:

828136

result:

ok single line: '828136'

Test #138:

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

input:

67108863 67108863
26
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432

output:

268435374

result:

ok single line: '268435374'

Test #139:

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

input:

37699200 88131400
9
170 1190 8330 41650 166600 1332800 5331200 31987200 191923200

output:

373796

result:

ok single line: '373796'

Test #140:

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

input:

51244800 79073120
10
170 1360 2720 16320 163200 326400 1958400 23500800 70502400 141004800

output:

35276

result:

ok single line: '35276'

Test #141:

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

input:

44927120 8395
11
365 1460 2920 5840 23360 116800 350400 1752000 3504000 21024000 105120000

output:

407729

result:

ok single line: '407729'

Subtask #10:

score: 1
Accepted

Test #142:

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

input:

1000000000 1000000000
1
1

output:

1000000000000000000

result:

ok single line: '1000000000000000000'

Test #143:

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

input:

1000000000 1000000000
1
1000000000

output:

1

result:

ok single line: '1'

Test #144:

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

input:

538298368 7843824
12
536 2144 6432 32160 128640 514560 1029120 5145600 20582400 82329600 411648000 823296000

output:

2654627

result:

ok single line: '2654627'

Test #145:

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

input:

547008670 463094425
17
5 15 30 90 180 360 1800 9000 27000 135000 270000 1080000 5400000 16200000 81000000 162000000 648000000

output:

478012321

result:

ok single line: '478012321'

Test #146:

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

input:

940497675 142572169
16
99 297 1188 2376 4752 9504 38016 190080 570240 1140480 2280960 4561920 22809600 91238400 364953600 729907200

output:

-1

result:

ok single line: '-1'

Test #147:

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

input:

89415916 307375364
18
1 5 15 75 300 1200 2400 4800 24000 48000 240000 1200000 3600000 7200000 14400000 57600000 230400000 921600000

output:

725248359

result:

ok single line: '725248359'

Test #148:

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

input:

248531095 728447144
30
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912

output:

1367395931

result:

ok single line: '1367395931'

Test #149:

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

input:

882294826 207974567
22
1 2 6 12 36 108 216 648 1944 5832 11664 34992 104976 314928 629856 1259712 3779136 11337408 34012224 102036672 204073344 612220032

output:

2210063519

result:

ok single line: '2210063519'

Test #150:

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

input:

572703670 655340210
5
21070 1306340 14369740 186806620 560419860

output:

1898289

result:

ok single line: '1898289'

Test #151:

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

input:

509534368 841478138
4
514 66820 6615180 932740380

output:

128452429

result:

ok single line: '128452429'

Test #152:

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

input:

136095318 28044000
5
738 13284 106272 531360 2656800

output:

493967

result:

ok single line: '493967'

Test #153:

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

input:

116553905 100601875
3
5 560 7235200

output:

5398476965

result:

ok single line: '5398476965'

Test #154:

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

input:

1000000000 1000000000
30
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912

output:

5087317

result:

ok single line: '5087317'

Test #155:

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

input:

536870911 536870911
29
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456

output:

2147483557

result:

ok single line: '2147483557'

Test #156:

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

input:

305484928 621492480
10
367 2936 23488 117440 822080 1644160 9864960 29594880 177569280 887846400

output:

50379

result:

ok single line: '50379'

Test #157:

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

input:

688905000 736716875
9
625 1875 13125 118125 1063125 3189375 28704375 344452500 688905000

output:

4405561

result:

ok single line: '4405561'

Test #158:

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

input:

818425152 896532480
14
912 1824 3648 10944 43776 87552 350208 1400832 2801664 5603328 22413312 89653248 358612992 717225984

output:

297307

result:

ok single line: '297307'

Test #159:

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

input:

895104000 243617472
13
777 1554 3108 12432 49728 248640 745920 3729600 11188800 22377600 89510400 447552000 895104000

output:

77460

result:

ok single line: '77460'

Test #160:

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

input:

17262 442654884
15
126 378 1890 3780 11340 34020 170100 680400 1360800 2721600 13608000 54432000 163296000 326592000 979776000

output:

7417070

result:

ok single line: '7417070'

Extra Test:

score: 0
Extra Test Passed