DCP-452: Number Pyramid Back to All Problems

Medium Math > Basic Math


You probably heard of number pyramid. Its looks like this: ![enter image description here][1] Easy and cute, isn’t it? Now You have to find summation of a sub triangle. For example: ![enter image description here][2] Edge of this sub-triangle is - row 2, column 2 and value 3 - row 4, column 2 and value 8 - row 4, column 4 and value 10 And summation of this sub-triangle is 41. You can assume the sub-triangle to be equilateral triangle, Every side of the sub-triangle contains same amount of numbers. And the result should be a positive number. Input: ------ Input starts with an integer **T (1<= T <=3000)**, denoting the number of test cases. Each case contains 3 lines, denoting the **3** points of the triangle. Each Line will have **2** numbers: **X** and **Y** , denoting a point of the sub-triangle. You can safely assume that all point of triangle will be valid and **1** <= **Y** <= **X** <= **3000** . Point **X** , **Y** means number of **X** th row and **Y** th column. They are not necessarily ordered. Output: ------- For each case of input, output the summation of the sub-triangle modulo 1E9 + 7 ( 1000000007 ) Sample Input ------------ 2 2 2 4 2 4 4 1 1 2 1 2 2 Sample Output ------------- 41 6 [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/d95dd904-ac1e-c7e1-2144-08d53bfa26ec_ebfcf2ea60ad4289b8e9723ef16407d2_W297xH160.png [2]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/c2afb591-fa89-cd57-d820-08d53bfa31c0_375f978bfa5c454596ad3cbb031cca11_W263xH145.png


Problem Setter:

S. M. Riasat Ali

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

49/264

Solve/Submission

Ranking

# User Language Timing
01 feodorv C 0.01s
02 Mohimenol_Fahim Cpp 0.03s
03 Madhab Cpp 0.03s
04 islam2366 C 0.03s
05 31_ipn Cpp 0.03s
06 Mushfiqur_Rahman Cpp 0.03s
07 Asif_Watson Cpp 0.05s
08 rabbycse Cpp14 0.05s
09 shamimjucse Cpp 0.05s
10 shahadat191 Cpp 0.05s
11 sakib_cse17 Cpp 0.06s
12 fayedanik Cpp14 0.06s
13 pencil Cpp 0.06s
14 mahbubcseju Cpp 0.09s
15 PKP_007 Cpp 0.09s
16 Rajib_119 Cpp 0.09s
17 SAIF_IIT8_JU Cpp 0.09s
18 kabbya Cpp 0.10s
19 fuad036 Cpp 0.11s
20 neel71 Cpp14 0.12s
21 shahjalalshohag Cpp14 0.12s
22 tahsin_protik Cpp 0.12s
23 mir003 Cpp 0.13s
24 tariqiitju Cpp14 0.13s
25 Fuad_Islam Cpp 0.16s
26 mahade31 Cpp 0.18s
27 mh755628 Cpp14 0.22s
28 sayedgkm Cpp14 0.23s
29 DynamicOvi Cpp 0.25s
30 warriors_of_7 Cpp 0.26s
31 _c_k_r_ Cpp 0.26s
32 snow_man Cpp14 0.26s
33 Nobel Cpp 0.28s
34 Masum_ice Cpp 0.34s
35 Robin008 Cpp 0.35s
36 anik_JU Cpp 0.39s
37 badassiumoxide Cpp 0.39s
38 emrul Cpp14 0.42s
39 ksohan Cpp 0.44s
40 Taran Cpp14 0.44s
41 SakibAlamin Cpp14 0.48s
42 Ishraq_Nibir Cpp 0.60s
43 AmdSadi Cpp 0.69s
44 Turin Cpp 0.70s
45 shahed95 Cpp 0.79s
46 Dalgerok Cpp 0.88s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support