All Tracks Algorithms Sorting Heap Sort Problem

Cube Change
Tag(s):

Easy, Math, Simple-math

Problem
Editorial
Analytics

Chandan gave his son a cube with side N. The N X N X N cube is made up of small 1 X 1 X 1 cubes.

Chandan's son is extremely notorious just like him. So he dropped the cube inside a tank filled with Coke. The cube got totally immersed in that tank. His son was somehow able to take out the cube from the tank. But sooner his son realized that the cube had gone all dirty because of the coke. Since Chandan did not like dirty stuffs so his son decided to scrap off all the smaller cubes that got dirty in the process. A cube that had coke on any one of its six faces was considered to be dirty and scrapped off. After completing this cumbersome part his son decided to calculate volume of the scrapped off material. Since Chandan's son is weak in maths he is unable to do it alone.

Help him in calculating the required volume.

Input:

The first line contains T denoting the number of test cases. Then T lines follow each line contains N that is the side of cube.

Output:

For each case output the required volume.

Constraints:

  • 1 ≤ T ≤ 100
  • 1 ≤ N ≤ 109

Note:

There is no hole or space between 2 smaller cubes.

SAMPLE INPUT
2
1
3
SAMPLE OUTPUT
1
26
Explanation

For the first test case : There is only 1 small cube in a 1 x 1 x 1 cube. This cube gets coke on all of its 6 faces so it needs to be scrapped off. Volume of material that gets scrapped is 1 x 1 x 1 = 1.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

IndiaHacks: Algorithms Qualifiers Round 2

OTHER PROBLEMS OF THIS CHALLENGE
通知
View All Notifications

?