Codevs 2956 Queuing problem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.