DCP-348: Marvel Smartest Vol. 2 Back to All Problems

Medium Divide and Conquer > Dynamic Programming

Tony Stark can’t believe it. Dr.Doom is back. One of the smartest anti-heroes alive in Marvel Universe. “I can’t recognize you.” said, Iron Man. “Well , the scars in my face?They are gone now, through mystical things”, replied the dethroned ruler of Latveria. Tony said in a cold voice, “Let me check again: I will ask you a question. You need to answer it within **2** minutes to prove that you are indeed the smart, genius and equally frightening Dr.Victor Von Doom, standing in front of me. And the question is-In how many ways you can express an integer **n** ( **2<=n<=100000**) as the sum of one or more integers who are greater than or equal to 2?” Input: ------ Input will consist of **N+1** lines in separate line( **1<=N <=100000**) First line will contain **N**, the number of values of **n**. Next N line will contain one integer each denoting the value of **n**. Output: ------- For each n, print the number of way you can express n as the sum of one or more integers greater than **2**. You should print the answer modulo **10^9+7**. Sample Input ------------ 3 3 4 5 Sample Output ------------- 1 2 3 Explanation: There are 3 inputs: n=3,4,5 For n=3, possible expressions are 3= { 3}=>1 way For n=4, possible expressions are 4={ 4 , 2+2}=>2 ways For n=5 , possible expressions are 5={5,2+3,3+2}=>3 ways

Problem Setter:

Mir Imtiaz Mostafiz

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




# User Language Timing
01 Koushik_12 Cpp14 0.00s
02 Mahmudul_Tushar Cpp 0.00s
03 nafiz0080 Cpp14 0.00s
04 Double_O Cpp14 0.00s
05 njrafi Cpp 0.00s
06 sakib_ruet_13 Cpp14 0.00s
07 ssavi Cpp14 0.00s
08 subhashis_cse C 0.00s
09 as_couple Cpp14 0.00s
10 rabel Cpp14 0.00s
11 tariqiitju C 0.00s
12 Ishrak Cpp 0.00s
13 prodipdatta7 Cpp14 0.00s
14 mno123 Cpp 0.00s
15 Sarwar05 Cpp 0.00s
16 moshiur_cse15 Cpp14 0.00s
17 feodorv C 0.00s
18 Morass Cpp14 0.00s
19 clkjwdhc Cpp 0.00s
20 prateepm Cpp14 0.01s
21 kissu_pari_na Cpp 0.01s
22 Islam_Rafat Cpp14 0.01s
23 Jisancse Cpp14 0.01s
24 sazal_dev Cpp 0.01s
25 Mr_adnan Cpp14 0.01s
26 Masum_ice Cpp14 0.01s
27 haasib Cpp 0.01s
28 shaft Cpp 0.01s
29 dmehrab06 Cpp14 0.01s
30 mahbubcseju Cpp14 0.01s
31 ksohan Cpp 0.01s
32 Zeronfinity Cpp14 0.01s
33 nasif2587 Cpp14 0.01s
34 swapnil Cpp14 0.02s
35 alttlprgrmmng Cpp 0.02s
36 hashtag33 Cpp 0.02s
37 simantaturja Cpp 0.02s
38 robin_aust Cpp 0.02s
39 emrul Cpp14 0.02s
40 rayhan50001 Cpp 0.02s
41 zerin_xahan Cpp 0.02s
42 I_See_You Cpp14 0.03s
43 unknown420 Cpp14 0.22s

Your feedback is our precious!

Or call +88 02 9853138 for support