Statistics

Problem Statement for "FrozenStandings"

Problem Statement

The final round of Top Cat Open 2014 is over! However, we do not know the final standings yet because the scoreboard has been frozen for the last hour.

There are N contestants in the final round. They are numbered 0 through N-1 according to the results of the previous round. According to the frozen standings, contestant i has already solved X[i] problems. After the standings have been frozen, each contestant was only allowed to solve one additional problem. Thus, for each i the actual number of problems solved by contestant i is either X[i] or X[i] + 1.

In the final standings the contestants will be ordered by the number of problems solved (more is better). In case of a tie the contestant with a smaller number will have the better place.

The array X is generated from given ints A and seed. Use the following pseudocode to generate X:
64bit_integer x = seed;
for (i = 0; i < N; i++) {
    x = x * 20142014 % 1000000007;
    X[i] = x % A;
}


How many different rankings are possible at the end of the contest? Return this value modulo 1,000,000,007.

Definition

Class:
FrozenStandings
Method:
countStandings
Parameters:
int, int, int
Returns:
int
Method signature:
int countStandings(int N, int A, int seed)
(be sure your method is public)

Constraints

  • N will be between 1 and 500,000, inclusive.
  • A will be between 1 and 500,000, inclusive.
  • seed will be between 1 and 1,000,000,006, inclusive.

Examples

  1. 3

    3

    2137378

    Returns: 2

    The array X will be {0, 2, 2}. If contestant 2 solved one more problem during the last hour but contestant 1 did not, the final ranking will be (2,1,0). Otherwise the final ranking will be (1,2,0).

  2. 1

    1

    565225711

    Returns: 1

    The array X will be {0}.

  3. 5

    1

    765276374

    Returns: 27

    The array X will be {0, 0, 0, 0, 0}.

  4. 8

    2

    667363653

    Returns: 226

    The array X will be {1, 0, 1, 1, 1, 0, 1, 1}.

  5. 20

    4

    765276374

    Returns: 933806

    The array X will be {3, 3, 2, 3, 1, 0, 3, 1, 3, 0, 1, 3, 2, 1, 0, 1, 0, 3, 2, 1}.

  6. 500000

    100

    123456789

    Returns: 482934470

  7. 500000

    1

    519250411

    Returns: 967131222

  8. 500000

    1

    95631118

    Returns: 967131222

  9. 500000

    1

    187586530

    Returns: 967131222

  10. 500000

    1

    265376751

    Returns: 967131222

  11. 500000

    1

    142232182

    Returns: 967131222

  12. 500000

    2

    897576132

    Returns: 242696728

  13. 500000

    2

    125068896

    Returns: 836583755

  14. 500000

    2

    861796586

    Returns: 782868353

  15. 500000

    2

    561547212

    Returns: 736429519

  16. 500000

    2

    590315948

    Returns: 937264137

  17. 500000

    3

    377145873

    Returns: 202610805

  18. 500000

    3

    716199354

    Returns: 273839196

  19. 500000

    3

    709244277

    Returns: 304940343

  20. 500000

    3

    362451667

    Returns: 489754085

  21. 500000

    3

    58954005

    Returns: 169646306

  22. 500000

    4

    80617800

    Returns: 959125713

  23. 500000

    5

    902358027

    Returns: 754652191

  24. 500000

    6

    379290125

    Returns: 586468961

  25. 500000

    7

    895850760

    Returns: 665740316

  26. 500000

    8

    40537806

    Returns: 749502325

  27. 500000

    9

    541593165

    Returns: 540954372

  28. 500000

    10

    556476263

    Returns: 451757209

  29. 500000

    16

    237982805

    Returns: 947120666

  30. 500000

    32

    991900216

    Returns: 621878897

  31. 500000

    64

    923939675

    Returns: 22285854

  32. 500000

    128

    694457773

    Returns: 108497652

  33. 500000

    256

    478760814

    Returns: 802202755

  34. 500000

    512

    144385324

    Returns: 35627417

  35. 500000

    1024

    629303436

    Returns: 83725064

  36. 500000

    2048

    213770903

    Returns: 736979896

  37. 500000

    4096

    114471170

    Returns: 662581380

  38. 500000

    8192

    717029620

    Returns: 343880006

  39. 500000

    16384

    649340539

    Returns: 751434004

  40. 500000

    32768

    206734362

    Returns: 354296522

  41. 500000

    65536

    405274810

    Returns: 515136334

  42. 500000

    131072

    291766580

    Returns: 368187458

  43. 500000

    262144

    928763678

    Returns: 449979552

  44. 500000

    500000

    741796964

    Returns: 501545732

  45. 500000

    500000

    360256101

    Returns: 612020017

  46. 500000

    500000

    824345074

    Returns: 938585338

  47. 500000

    500000

    526708173

    Returns: 213615034

  48. 500000

    500000

    112914283

    Returns: 174985997

  49. 423458

    1

    949948944

    Returns: 112042571

  50. 373828

    1

    558583823

    Returns: 477554873

  51. 23211

    1

    442446780

    Returns: 140605250

  52. 176338

    1

    921333394

    Returns: 593179935

  53. 411953

    1

    512572382

    Returns: 702622078

  54. 483535

    2

    621117970

    Returns: 853328917

  55. 20147

    2

    824284065

    Returns: 258463483

  56. 463147

    2

    155045233

    Returns: 58511148

  57. 365249

    2

    143409881

    Returns: 456833239

  58. 237930

    2

    272934246

    Returns: 95579415

  59. 130359

    3

    237909481

    Returns: 212209150

  60. 44118

    3

    411883325

    Returns: 884207573

  61. 345933

    3

    224182395

    Returns: 489470039

  62. 259999

    3

    443849912

    Returns: 430797982

  63. 453674

    3

    474722482

    Returns: 405172840

  64. 112107

    4

    76151679

    Returns: 686637123

  65. 166829

    5

    383221681

    Returns: 865496167

  66. 316922

    6

    827261919

    Returns: 418374461

  67. 214761

    7

    41045349

    Returns: 132523877

  68. 384054

    8

    358258325

    Returns: 531586250

  69. 188868

    9

    996637423

    Returns: 348513858

  70. 238266

    10

    20478855

    Returns: 628495728

  71. 453877

    16

    530263928

    Returns: 174462135

  72. 224609

    32

    952170923

    Returns: 914087210

  73. 446572

    64

    554245691

    Returns: 728098977

  74. 290596

    128

    902707522

    Returns: 865394167

  75. 184429

    256

    683831022

    Returns: 474990298

  76. 410557

    512

    482885036

    Returns: 322364490

  77. 227446

    1024

    532332352

    Returns: 825586878

  78. 369674

    2048

    321889599

    Returns: 458066700

  79. 270152

    4096

    786253257

    Returns: 572924033

  80. 87382

    8192

    651715476

    Returns: 525351011

  81. 83493

    16384

    545913333

    Returns: 159748027

  82. 407685

    32768

    556992282

    Returns: 729693210

  83. 164047

    65536

    55859250

    Returns: 354843007

  84. 471881

    131072

    451428048

    Returns: 912369408

  85. 303513

    262144

    326630576

    Returns: 933834910

  86. 114874

    500000

    35109600

    Returns: 707415695

  87. 109035

    500000

    438997865

    Returns: 761285486

  88. 487414

    500000

    345936604

    Returns: 17276329

  89. 419250

    500000

    986395492

    Returns: 947416038

  90. 171359

    500000

    300693229

    Returns: 823714282


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: