2956 Queuing Problems
time limit: 1 s space limit: 32000 KB title level: Golden Gold
Title Description
Description
There are n students go to the canteen, can instructors rule: must 2 or 3 people form a group, ask how many different methods of grouping.
Enter a description
Input Description
A number, N
Output description
Output Description
A number, that is the answer.
Sample input
Sample Input
6
Sample output
Sample Output
2
Data range and Tips
Data Size & Hint
n<=150
50 points tle Code archive:
1#include <iostream>2#include <cstring>3#include <cstdio>4 using namespacestd;5 intN,ans;6 voidDfsintx)7 {8 if(x==0){9ans++;return ; Ten } One Else if(x<2&&x!=0)return; ADFS (X-2); -DFS (X-3); - } the intMain () - { -scanf"%d",&n); - DFS (n); +printf"%d", ans); - return 0; +}
Positive solution:
1#include <cstdio>2 #definell Long Long3 using namespacestd;4ll f[155];5 intMain () {6 intN;7scanf"%d", &n);8f[1]=0; f[2]=f[3]=1;9 for(intI=4; i<=n;i++) f[i]=f[i-2]+f[i-3];Tenprintf"%lld\n", F[n]); One return 0; A } - //This question is actually a recursive!!!!!!
Codevs 2956 Queuing problem