Statistics

Problem Statement for "SimpleMazeEasy"

Problem Statement

A level-n simple maze consists of five squares arranged into the shape of a cross. Each square consists of n times n rooms, each having the shape of a unit square. Simple mazes of level 1 and level 3 are shown below, with each '.' representing one cell.

 .
...
 .

   ...
   ...
   ...
.........
.........
.........
   ...
   ...
   ...


In a single step you can move from your current room into any room that shares a side with your room. The distance between two rooms is the smallest number of steps needed to get from one room to the other.

You are given the long n. Consider the level-n simple maze. For each pair of rooms compute their distance. Let S be the sum of all those distances. Compute and return the value S modulo (10^9 + 7).

Definition

Class:
SimpleMazeEasy
Method:
findSum
Parameters:
long
Returns:
int
Method signature:
int findSum(long n)
(be sure your method is public)

Constraints

  • n will be between 1 and 1,000,000,000,000,000,000 (10^18), inclusive.

Examples

  1. 1

    Returns: 16

    The level-1 simple maze consists of five rooms. There are four pairs of adjacent rooms (i.e., distance = 1). There are six pairs of rooms that are at distance 2. Thus, the sum of all distances is 4*1 + 6*2 = 16.

  2. 3

    Returns: 4680

  3. 5

    Returns: 61000

  4. 12345

    Returns: 598011702

    don't forget mod.

  5. 1000000000000

    Returns: 763641672

  6. 1000000000000000000

    Returns: 554915149

  7. 66

    Returns: 628153008

  8. 430013829

    Returns: 534334024

  9. 68

    Returns: 592873724

  10. 14561493

    Returns: 420928395

  11. 7521949216195539

    Returns: 682736322

  12. 53601

    Returns: 823158687

  13. 517954936

    Returns: 179572644

  14. 189717349401640931

    Returns: 235159525

  15. 16069892689614323

    Returns: 306252769

  16. 631189381

    Returns: 944669236

  17. 198721747201307

    Returns: 940906601

  18. 41

    Returns: 278252562

  19. 99471198180814

    Returns: 166478912

  20. 3098959

    Returns: 65987364

  21. 7

    Returns: 329280

  22. 9567586

    Returns: 351224857

  23. 4

    Returns: 19904

  24. 75398296

    Returns: 218998828

  25. 22368077

    Returns: 167750101

  26. 33304207618616404

    Returns: 126302287

  27. 72441281041

    Returns: 87223761

  28. 20441774562623195

    Returns: 234574084

  29. 836141540

    Returns: 768290544

  30. 386804888689515616

    Returns: 272743712

  31. 48522212

    Returns: 989321214

  32. 6365581

    Returns: 676049544

  33. 177515021252

    Returns: 153940392

  34. 1483333207

    Returns: 152311723

  35. 93311

    Returns: 790896145

  36. 81051371

    Returns: 73940737

  37. 4

    Returns: 19904

  38. 466366962037226

    Returns: 643063976

  39. 912519710998

    Returns: 957768365

  40. 8515593382727400

    Returns: 546341048

  41. 2584652203264

    Returns: 375620857

  42. 4505666462392

    Returns: 164181764

  43. 4

    Returns: 19904

  44. 9

    Returns: 1158624

  45. 687684854695598

    Returns: 985660829

  46. 48

    Returns: 10739165

  47. 874006492843456

    Returns: 17571338

  48. 22520907890017

    Returns: 805954087

  49. 6261301015171531

    Returns: 109084532

  50. 5

    Returns: 61000

  51. 48410208570300

    Returns: 68830091

  52. 57973059015872

    Returns: 936184209

  53. 6347609025362

    Returns: 432522339

  54. 763940625684

    Returns: 94636593

  55. 204072734326952

    Returns: 593731594

  56. 45

    Returns: 628718979

  57. 3175

    Returns: 619182891

  58. 65204063000

    Returns: 23798160

  59. 53071

    Returns: 85925862

  60. 5613160155

    Returns: 68420953

  61. 847852

    Returns: 637892515

  62. 32247400

    Returns: 899720800

  63. 38445537

    Returns: 494251970

  64. 484375357

    Returns: 524130368

  65. 7357741039221262

    Returns: 902830376

  66. 8753565

    Returns: 588315917

  67. 123

    Returns: 669957529

  68. 10000000000

    Returns: 947491238

  69. 999999999999999873

    Returns: 220644519

  70. 123545

    Returns: 371583578

  71. 100000000000000

    Returns: 407467142

  72. 25

    Returns: 192000000

  73. 2321321312321

    Returns: 918825480


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: