QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#18798#2115. Od deski do deski [A]Elegia10 ✓40ms58840kbC++171.0kb2022-01-27 13:49:352022-05-06 02:40:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 02:40:01]
  • 评测
  • 测评结果:10
  • 用时:40ms
  • 内存:58840kb
  • [2022-01-27 13:49:35]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ull = unsigned long long;

const int P = 1e9 + 7;

int norm(int x) { return x >= P ? x - P : x; }
int reduce(int x) { return x < 0 ? x + P : x; }
int neg(int x) { return x ? P - x : 0; }
void add(int& x, int y) { if ((x += y - P) < 0) x += P; }
void sub(int& x, int y) { if ((x -= y) < 0) x += P; }
void fam(int& x, int y, int z) { x = (x + y * (ull)z) % P; }
int mpow(int x, unsigned k) {
	if (k == 0) return 1;
	int ret = mpow(x * (ull)x % P, k >> 1);
	if (k & 1) ret = ret * (ull)x % P;
	return ret;
}

const int _ = 3010;

int f[_][_], g[_][_];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

	int N, M; cin >> N >> M;
	f[0][0] = 1;
	for (int i = 0; i != N; ++i)
		for (int j = 0; j <= i; ++j) {
			fam(f[i + 1][j], f[i][j], j);
			fam(g[i + 1][j + 1], f[i][j], M - j);
			fam(f[i + 1][j], g[i][j], j);
			fam(g[i + 1][j], g[i][j], M - j);
		}
	int ans = accumulate(f[N], f[N] + N + 1, 0ULL) % P;
	cout << ans << '\n';

	return 0;
}

詳細信息

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 3ms
memory: 5660kb

input:

4 2

output:

10

result:

ok single line: '10'

Test #2:

score: 0
Accepted
time: 3ms
memory: 5584kb

input:

1 1

output:

0

result:

ok single line: '0'

Test #3:

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

input:

1 3

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 4ms
memory: 5684kb

input:

1 5

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 2ms
memory: 5708kb

input:

2 2

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 3ms
memory: 5640kb

input:

2 4

output:

4

result:

ok single line: '4'

Test #7:

score: 0
Accepted
time: 6ms
memory: 5728kb

input:

3 1

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 4ms
memory: 5708kb

input:

3 3

output:

9

result:

ok single line: '9'

Test #9:

score: 0
Accepted
time: 3ms
memory: 5636kb

input:

3 5

output:

25

result:

ok single line: '25'

Test #10:

score: 0
Accepted
time: 3ms
memory: 5532kb

input:

4 2

output:

10

result:

ok single line: '10'

Test #11:

score: 0
Accepted
time: 3ms
memory: 3720kb

input:

4 4

output:

76

result:

ok single line: '76'

Test #12:

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

input:

5 1

output:

1

result:

ok single line: '1'

Test #13:

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

input:

5 3

output:

117

result:

ok single line: '117'

Test #14:

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

input:

5 5

output:

825

result:

ok single line: '825'

Test #15:

score: 0
Accepted
time: 8ms
memory: 3596kb

input:

7 2

output:

116

result:

ok single line: '116'

Test #16:

score: 0
Accepted
time: 3ms
memory: 3760kb

input:

9 2

output:

496

result:

ok single line: '496'

Test #17:

score: 0
Accepted
time: 2ms
memory: 3756kb

input:

11 2

output:

2028

result:

ok single line: '2028'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3756kb

input:

13 2

output:

8168

result:

ok single line: '8168'

Test #19:

score: 0
Accepted
time: 3ms
memory: 3684kb

input:

10 3

output:

48237

result:

ok single line: '48237'

Subtask #2:

score: 1
Accepted

Test #20:

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

input:

1 2

output:

0

result:

ok single line: '0'

Test #21:

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

input:

1 4

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 4ms
memory: 3688kb

input:

2 1

output:

1

result:

ok single line: '1'

Test #23:

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

input:

2 3

output:

3

result:

ok single line: '3'

Test #24:

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

input:

2 5

output:

5

result:

ok single line: '5'

Test #25:

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

input:

3 2

output:

4

result:

ok single line: '4'

Test #26:

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

input:

3 4

output:

16

result:

ok single line: '16'

Test #27:

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

input:

4 1

output:

1

result:

ok single line: '1'

Test #28:

score: 0
Accepted
time: 3ms
memory: 3772kb

input:

4 3

output:

33

result:

ok single line: '33'

Test #29:

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

input:

4 5

output:

145

result:

ok single line: '145'

Test #30:

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

input:

5 2

output:

24

result:

ok single line: '24'

Test #31:

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

input:

5 4

output:

352

result:

ok single line: '352'

Test #32:

score: 0
Accepted
time: 2ms
memory: 3784kb

input:

6 2

output:

54

result:

ok single line: '54'

Test #33:

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

input:

8 2

output:

242

result:

ok single line: '242'

Test #34:

score: 0
Accepted
time: 3ms
memory: 3688kb

input:

10 2

output:

1006

result:

ok single line: '1006'

Test #35:

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

input:

12 2

output:

4074

result:

ok single line: '4074'

Test #36:

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

input:

14 2

output:

16358

result:

ok single line: '16358'

Subtask #3:

score: 1
Accepted

Test #37:

score: 1
Accepted
time: 8ms
memory: 28176kb

input:

1689 2

output:

998472085

result:

ok single line: '998472085'

Test #38:

score: 0
Accepted
time: 16ms
memory: 52820kb

input:

2748 2

output:

451726470

result:

ok single line: '451726470'

Test #39:

score: 0
Accepted
time: 7ms
memory: 18888kb

input:

1204 2

output:

449822862

result:

ok single line: '449822862'

Test #40:

score: 0
Accepted
time: 25ms
memory: 52464kb

input:

2727 2

output:

203224669

result:

ok single line: '203224669'

Test #41:

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

input:

984 2

output:

175698237

result:

ok single line: '175698237'

Test #42:

score: 0
Accepted
time: 14ms
memory: 58836kb

input:

3000 2

output:

165694478

result:

ok single line: '165694478'

Subtask #4:

score: 1
Accepted

Test #43:

score: 1
Accepted
time: 4ms
memory: 4388kb

input:

97 83

output:

613159502

result:

ok single line: '613159502'

Test #44:

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

input:

109 112

output:

749531455

result:

ok single line: '749531455'

Test #45:

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

input:

92 84

output:

754509307

result:

ok single line: '754509307'

Test #46:

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

input:

111 116

output:

434377961

result:

ok single line: '434377961'

Test #47:

score: 0
Accepted
time: 4ms
memory: 4368kb

input:

95 82

output:

345936119

result:

ok single line: '345936119'

Test #48:

score: 0
Accepted
time: 3ms
memory: 4472kb

input:

106 94

output:

551192069

result:

ok single line: '551192069'

Test #49:

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

input:

110 94

output:

41938476

result:

ok single line: '41938476'

Subtask #5:

score: 1
Accepted

Test #50:

score: 1
Accepted
time: 3ms
memory: 18336kb

input:

1168 346407973

output:

112579949

result:

ok single line: '112579949'

Test #51:

score: 0
Accepted
time: 3ms
memory: 6512kb

input:

313 68910142

output:

83916341

result:

ok single line: '83916341'

Test #52:

score: 0
Accepted
time: 2ms
memory: 4964kb

input:

161 64396010

output:

499230829

result:

ok single line: '499230829'

Test #53:

score: 0
Accepted
time: 17ms
memory: 31580kb

input:

1836 434479347

output:

873178296

result:

ok single line: '873178296'

Test #54:

score: 0
Accepted
time: 4ms
memory: 26168kb

input:

1588 392

output:

611721416

result:

ok single line: '611721416'

Subtask #6:

score: 1
Accepted

Test #55:

score: 1
Accepted
time: 4ms
memory: 4624kb

input:

123 468402382

output:

827499041

result:

ok single line: '827499041'

Test #56:

score: 0
Accepted
time: 2ms
memory: 15768kb

input:

1016 982915840

output:

813922878

result:

ok single line: '813922878'

Test #57:

score: 0
Accepted
time: 3ms
memory: 11280kb

input:

709 58889328

output:

215179237

result:

ok single line: '215179237'

Test #58:

score: 0
Accepted
time: 7ms
memory: 13736kb

input:

884 504516691

output:

199072709

result:

ok single line: '199072709'

Test #59:

score: 0
Accepted
time: 11ms
memory: 22812kb

input:

1414 131

output:

292793609

result:

ok single line: '292793609'

Subtask #7:

score: 1
Accepted

Test #60:

score: 1
Accepted
time: 1ms
memory: 12196kb

input:

779 140176290

output:

438118426

result:

ok single line: '438118426'

Test #61:

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

input:

488 292223807

output:

720591335

result:

ok single line: '720591335'

Test #62:

score: 0
Accepted
time: 7ms
memory: 13196kb

input:

849 198249514

output:

936832149

result:

ok single line: '936832149'

Test #63:

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

input:

929 316667619

output:

684900471

result:

ok single line: '684900471'

Test #64:

score: 0
Accepted
time: 5ms
memory: 20316kb

input:

1282 216

output:

39918106

result:

ok single line: '39918106'

Subtask #8:

score: 1
Accepted

Test #65:

score: 1
Accepted
time: 17ms
memory: 42652kb

input:

2315 21373850

output:

692830582

result:

ok single line: '692830582'

Test #66:

score: 0
Accepted
time: 16ms
memory: 54436kb

input:

2819 54930015

output:

704850526

result:

ok single line: '704850526'

Test #67:

score: 0
Accepted
time: 16ms
memory: 55784kb

input:

2876 518453378

output:

160061956

result:

ok single line: '160061956'

Test #68:

score: 0
Accepted
time: 23ms
memory: 52188kb

input:

2722 126086649

output:

930849830

result:

ok single line: '930849830'

Test #69:

score: 0
Accepted
time: 23ms
memory: 47204kb

input:

2508 121810583

output:

5167845

result:

ok single line: '5167845'

Test #70:

score: 0
Accepted
time: 3ms
memory: 46960kb

input:

2500 4000

output:

805467400

result:

ok single line: '805467400'

Subtask #9:

score: 1
Accepted

Test #71:

score: 1
Accepted
time: 24ms
memory: 50072kb

input:

2631 684393357

output:

936211679

result:

ok single line: '936211679'

Test #72:

score: 0
Accepted
time: 22ms
memory: 56704kb

input:

2913 516585428

output:

664802101

result:

ok single line: '664802101'

Test #73:

score: 0
Accepted
time: 26ms
memory: 57888kb

input:

2966 566883908

output:

74800796

result:

ok single line: '74800796'

Test #74:

score: 0
Accepted
time: 16ms
memory: 47040kb

input:

2508 135568838

output:

345174594

result:

ok single line: '345174594'

Test #75:

score: 0
Accepted
time: 15ms
memory: 57576kb

input:

2948 557406795

output:

163500664

result:

ok single line: '163500664'

Test #76:

score: 0
Accepted
time: 15ms
memory: 46944kb

input:

2500 1000

output:

996821828

result:

ok single line: '996821828'

Subtask #10:

score: 1
Accepted

Test #77:

score: 1
Accepted
time: 38ms
memory: 58752kb

input:

3000 1000000000

output:

543073891

result:

ok single line: '543073891'

Test #78:

score: 0
Accepted
time: 11ms
memory: 58620kb

input:

3000 999999999

output:

453659722

result:

ok single line: '453659722'

Test #79:

score: 0
Accepted
time: 23ms
memory: 58760kb

input:

3000 999999998

output:

98366752

result:

ok single line: '98366752'

Test #80:

score: 0
Accepted
time: 38ms
memory: 58712kb

input:

2999 1000000000

output:

282559837

result:

ok single line: '282559837'

Test #81:

score: 0
Accepted
time: 29ms
memory: 58712kb

input:

2999 999999999

output:

720365773

result:

ok single line: '720365773'

Test #82:

score: 0
Accepted
time: 40ms
memory: 58684kb

input:

2999 999999998

output:

461705162

result:

ok single line: '461705162'

Test #83:

score: 0
Accepted
time: 23ms
memory: 58660kb

input:

2998 1000000000

output:

842668451

result:

ok single line: '842668451'

Test #84:

score: 0
Accepted
time: 16ms
memory: 58572kb

input:

2998 999999999

output:

304660083

result:

ok single line: '304660083'

Test #85:

score: 0
Accepted
time: 28ms
memory: 58840kb

input:

2998 999999998

output:

92840037

result:

ok single line: '92840037'

Test #86:

score: 0
Accepted
time: 15ms
memory: 58784kb

input:

3000 1

output:

1

result:

ok single line: '1'

Test #87:

score: 0
Accepted
time: 24ms
memory: 58804kb

input:

3000 100

output:

513574771

result:

ok single line: '513574771'