QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#69831#2115. Od deski do deski [A]mik2 1ms1736kbC++14594b2023-01-02 03:55:352023-01-02 03:55:36

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-02 03:55:36]
  • 评测
  • 测评结果:2
  • 用时:1ms
  • 内存:1736kb
  • [2023-01-02 03:55:35]
  • 提交

answer

#include <cstdio>

#define M 1000000007

int main (int argc, char **argv)
{
  int n, m, w = 1, a = 0, b = 0, pw = 0, pb = 0, x;
  scanf ("%i%i", &n, &m);
  if (n<2)
  {
    printf ("0\n");
    return 0;
  }
  for (int i=2; i<n; i++)
  {
    if(argc>1)printf("w=%i a=%i b=%i pw=%i pb=%i\n", w, a, b, pw, pb);
    x = b;
    b = (pw-pb+M+1ll*b*m)%M;
    pb = x;
    a = (w+a*(m-1ll))%M;
    x = w;
    w = (1ll*w*m)%M;
    pw = x;
  }
  if(argc>1)printf("w=%i a=%i b=%i pw=%i pb=%i\n", w, a, b, pw, pb);
  printf ("%lli\n", (1ll*m*w+(m*(m-1ll))%M*b)%M);
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

4 2

output:

10

result:

ok single line: '10'

Test #2:

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

input:

1 1

output:

0

result:

ok single line: '0'

Test #3:

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

input:

1 3

output:

0

result:

ok single line: '0'

Test #4:

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

input:

1 5

output:

0

result:

ok single line: '0'

Test #5:

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

input:

2 2

output:

2

result:

ok single line: '2'

Test #6:

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

input:

2 4

output:

4

result:

ok single line: '4'

Test #7:

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

input:

3 1

output:

1

result:

ok single line: '1'

Test #8:

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

input:

3 3

output:

9

result:

ok single line: '9'

Test #9:

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

input:

3 5

output:

25

result:

ok single line: '25'

Test #10:

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

input:

4 2

output:

10

result:

ok single line: '10'

Test #11:

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

input:

4 4

output:

76

result:

ok single line: '76'

Test #12:

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

input:

5 1

output:

1

result:

ok single line: '1'

Test #13:

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

input:

5 3

output:

117

result:

ok single line: '117'

Test #14:

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

input:

5 5

output:

825

result:

ok single line: '825'

Test #15:

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

input:

7 2

output:

116

result:

ok single line: '116'

Test #16:

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

input:

9 2

output:

496

result:

ok single line: '496'

Test #17:

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

input:

11 2

output:

2028

result:

ok single line: '2028'

Test #18:

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

input:

13 2

output:

8168

result:

ok single line: '8168'

Test #19:

score: -1
Wrong Answer
time: 0ms
memory: 1660kb

input:

10 3

output:

43545

result:

wrong answer 1st lines differ - expected: '48237', found: '43545'

Subtask #2:

score: 1
Accepted

Test #20:

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

input:

1 2

output:

0

result:

ok single line: '0'

Test #21:

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

input:

1 4

output:

0

result:

ok single line: '0'

Test #22:

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

input:

2 1

output:

1

result:

ok single line: '1'

Test #23:

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

input:

2 3

output:

3

result:

ok single line: '3'

Test #24:

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

input:

2 5

output:

5

result:

ok single line: '5'

Test #25:

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

input:

3 2

output:

4

result:

ok single line: '4'

Test #26:

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

input:

3 4

output:

16

result:

ok single line: '16'

Test #27:

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

input:

4 1

output:

1

result:

ok single line: '1'

Test #28:

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

input:

4 3

output:

33

result:

ok single line: '33'

Test #29:

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

input:

4 5

output:

145

result:

ok single line: '145'

Test #30:

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

input:

5 2

output:

24

result:

ok single line: '24'

Test #31:

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

input:

5 4

output:

352

result:

ok single line: '352'

Test #32:

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

input:

6 2

output:

54

result:

ok single line: '54'

Test #33:

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

input:

8 2

output:

242

result:

ok single line: '242'

Test #34:

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

input:

10 2

output:

1006

result:

ok single line: '1006'

Test #35:

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

input:

12 2

output:

4074

result:

ok single line: '4074'

Test #36:

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

input:

14 2

output:

16358

result:

ok single line: '16358'

Subtask #3:

score: 1
Accepted

Test #37:

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

input:

1689 2

output:

998472085

result:

ok single line: '998472085'

Test #38:

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

input:

2748 2

output:

451726470

result:

ok single line: '451726470'

Test #39:

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

input:

1204 2

output:

449822862

result:

ok single line: '449822862'

Test #40:

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

input:

2727 2

output:

203224669

result:

ok single line: '203224669'

Test #41:

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

input:

984 2

output:

175698237

result:

ok single line: '175698237'

Test #42:

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

input:

3000 2

output:

165694478

result:

ok single line: '165694478'

Subtask #4:

score: 0
Wrong Answer

Test #43:

score: 0
Wrong Answer
time: 0ms
memory: 1584kb

input:

97 83

output:

921432385

result:

wrong answer 1st lines differ - expected: '613159502', found: '921432385'

Subtask #5:

score: 0
Wrong Answer

Test #50:

score: 0
Wrong Answer
time: 1ms
memory: 1692kb

input:

1168 346407973

output:

666985361

result:

wrong answer 1st lines differ - expected: '112579949', found: '666985361'

Subtask #6:

score: 0
Wrong Answer

Test #55:

score: 0
Wrong Answer
time: 1ms
memory: 1736kb

input:

123 468402382

output:

801546540

result:

wrong answer 1st lines differ - expected: '827499041', found: '801546540'

Subtask #7:

score: 0
Wrong Answer

Test #60:

score: 0
Wrong Answer
time: 1ms
memory: 1600kb

input:

779 140176290

output:

425400722

result:

wrong answer 1st lines differ - expected: '438118426', found: '425400722'

Subtask #8:

score: 0
Wrong Answer

Test #65:

score: 0
Wrong Answer
time: 1ms
memory: 1732kb

input:

2315 21373850

output:

590939146

result:

wrong answer 1st lines differ - expected: '692830582', found: '590939146'

Subtask #9:

score: 0
Wrong Answer

Test #71:

score: 0
Wrong Answer
time: 1ms
memory: 1688kb

input:

2631 684393357

output:

103089992

result:

wrong answer 1st lines differ - expected: '936211679', found: '103089992'

Subtask #10:

score: 0
Wrong Answer

Test #77:

score: 0
Wrong Answer
time: 0ms
memory: 1492kb

input:

3000 1000000000

output:

394600438

result:

wrong answer 1st lines differ - expected: '543073891', found: '394600438'