Submit | All submissions | Best solutions | Back to list |
CRDS - Cards |
Maricruz have a lot of cards, she always uses her cards to build pyramids as shown in the following image:
A pyramid card of 3 levels. She always wonder how many cards does she need to make a pyramid card of N levels. Your task is to answer that question.
Input
The first line of the input contains an integer 1 <= T <= 1,000. Each of the following T lines will have an integer 1 <= N <= 1,000,000.
Output
For each case, output a single line consisting of the number of cards needed to build a pyramid card of level N modulo 1,000,007.
Example
Input Example 2 3 7 Output Example 15 77
Added by: | Paulo Costa |
Date: | 2012-01-30 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | UGTO |
hide comments
|
||||||||||||||
2015-08-25 18:38:59 shikhar
My 30th 3 lines code in python ...loved it |
||||||||||||||
2015-08-09 11:14:57
25th one... in spoj! :) |
||||||||||||||
2015-08-08 01:07:00 Medo
Doable with BigIntegers... |
||||||||||||||
2015-08-01 07:19:48
Thanks Tony T for clarifying the question. Got WA for taking number of cards needed to make (n mod 1000007) levels instead of taking (number of cards needed to make n levels) mod 1000007. Last edit: 2015-08-01 07:20:08 |
||||||||||||||
2015-07-17 03:26:12
Anyone know what structure should be used to solve a type error = runtime error (SIGSEGV) ? |
||||||||||||||
2015-06-29 22:23:23 Akshat Mathur
Too easy to complete 100 on spoj :-) |
||||||||||||||
2015-06-29 08:04:16 Pradd
4 lines in Python, around 11 in C++. There is a simple relationship between the number of cards and levels. Create a naive implementation first and study the relation for some aribitary values. You can then implement a simple one liner function to get the number of cards. |
||||||||||||||
2015-06-17 14:55:07
Using recursion here will be a disaster :P |
||||||||||||||
2015-06-08 15:16:04 Sidharth Yatish
Good problem :) Brute force won't work. Simple maths :) |
||||||||||||||
2015-05-22 23:07:14 Aguilar
5 WA ToT |