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

Mir Imtiaz Mostafiz

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 |

Solve/Submission

# | User | Language | Timing |
---|---|---|---|

01 | Mahmudul_Tushar | Cpp | 0.00s |

02 | njrafi | Cpp | 0.00s |

03 | nafiz0080 | Cpp14 | 0.00s |

04 | sakib_ruet_13 | Cpp14 | 0.00s |

05 | Ishrak | Cpp | 0.00s |

06 | prodipdatta7 | Cpp14 | 0.00s |

07 | mno123 | Cpp | 0.00s |

08 | ssavi | Cpp14 | 0.00s |

09 | as_couple | Cpp14 | 0.00s |

10 | Double_O | Cpp14 | 0.00s |

11 | subhashis_cse | C | 0.00s |

12 | tariqiitju | C | 0.00s |

13 | clkjwdhc | Cpp | 0.00s |

14 | Sarwar05 | Cpp | 0.00s |

15 | rabel | Cpp14 | 0.00s |

16 | Koushik_12 | Cpp14 | 0.00s |

17 | feodorv | C | 0.00s |

18 | moshiur_cse15 | Cpp14 | 0.00s |

19 | Morass | Cpp14 | 0.00s |

20 | Jisancse | Cpp14 | 0.01s |

21 | prateepm | Cpp14 | 0.01s |

22 | ksohan | Cpp | 0.01s |

23 | Mr_adnan | Cpp14 | 0.01s |

24 | sazal_dev | Cpp | 0.01s |

25 | Islam_Rafat | Cpp14 | 0.01s |

26 | mahbubcseju | Cpp14 | 0.01s |

27 | Masum_ice | Cpp14 | 0.01s |

28 | shaft | Cpp | 0.01s |

29 | Zeronfinity | Cpp14 | 0.01s |

30 | kissu_pari_na | Cpp | 0.01s |

31 | haasib | Cpp | 0.01s |

32 | nasif2587 | Cpp14 | 0.01s |

33 | dmehrab06 | Cpp14 | 0.01s |

34 | simantaturja | Cpp | 0.02s |

35 | alttlprgrmmng | Cpp | 0.02s |

36 | hashtag33 | Cpp | 0.02s |

37 | emrul | Cpp14 | 0.02s |

38 | swapnil | Cpp14 | 0.02s |

39 | robin_aust | Cpp | 0.02s |

40 | zerin_xahan | Cpp | 0.02s |

41 | rayhan50001 | Cpp | 0.02s |

42 | I_See_You | Cpp14 | 0.03s |

43 | unknown420 | Cpp14 | 0.22s |

Copyright © 2015-2016 Dev Skill.

Feedback
#### Your feedback is our precious!

## Thank you for providing feedback! Our developers will be happy :)

## Sorry there was a problem when submitting the feedback. Please try again. :(