Dry this bucket of iced tea! Time limit:1000msmemory limit:65536kb64-bit integer IO format:%lld Java class name: Main Prev Submit Status Statistics discuss Next
Bnucist's Hwq Special Love ice tea This kind of God stick of drink, one day playing DotA tyranny his bedroom WL, decided to shout a celebration. He decided to drink iced tea in a way that was only 1 liters per mouth, or 2 liters, or 3 liters (Ps:hwq can really drink so much =). Thinking Hwq suddenly want to know, for a bucket of whole number of ice tea, he can have how many kinds of solutions to drink light, but it seems he can't immediately come up with a solution, tangled he didn't know the answer he would not drink. Be smart, help him!
Input
Enter an integer t that represents the number of data groups.
For each set of data, enter an integer n,1<=n<=30, which indicates that the bucket of iced tea has N liters.
Output
For each n, output an integer that represents the number of scenarios.
Sample Input
13
Sample Output
4
Hint
For example, 3 litres of iced black tea, he can (1) Drink 1 liters each time, even drink 3 mouth; (2) Drink 1 liters at the first sip, 2 liters at the second mouth, (3) Drink 2 liters in the first SIP, 1 liters at the second, and 4 liters in one mouthful. So there are 4 kinds of programs.
Source2013 Beijing Normal University freshman program design contest problem-solving ideas: Through the front of the hand to launch behind. For any n can be divided into {{1,n-1},{2,n-2},{3,n-3}}, so sum[i]=sum[i-1]+sum[i-2]+sum[i-3];
#include <bits/stdc++.h>using namespace Std;int sum[50];int main () { int T; scanf ("%d", &t); sum[0]=1;sum[1]=1;sum[2]=2; for (int i=3;i<32;i++) { sum[i]=sum[i-1]+sum[i-2]+sum[i-3]; } while (t--) { int n; scanf ("%d", &n); printf ("%d\n", Sum[n]); } return 0;}
bnu34058--dry This bucket of iced tea! —————— "Recursion"