博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CODEVS——T 2956 排队问题
阅读量:4359 次
发布时间:2019-06-07

本文共 991 字,大约阅读时间需要 3 分钟。

 时间限制: 1 s
 空间限制: 32000 KB
 题目等级 : 黄金 Gold
 查看运行结果
 
 
题目描述 
Description

有N个学生去食堂,可教官规定:必须2人或3人组成一组,求有多少种不同分组的方法。

 

输入描述 
Input Description

一个数,N

输出描述 
Output Description

一个数,即答案。

样例输入 
Sample Input

6

样例输出 
Sample Output

2

数据范围及提示 
Data Size & Hint

N<=150

 

1 #include 
2 3 int n,ans; 4 5 void DFS(int sum) 6 { 7 if(sum>n) return ; 8 if(sum==n) { ans++; return ; } 9 if(sum+2<=n) DFS(sum+2);10 if(sum+3<=n) DFS(sum+3);11 }12 13 int Presist()14 {15 scanf("%d",&n);16 DFS(0);17 printf("%d\n",ans);18 return 0;19 }20 21 int Aptal=Presist();22 int main(int argc,char*argv[]){;}
深搜50
1 #include 
2 3 int n,ans; 4 long long f[155]; 5 6 int Presist() 7 { 8 scanf("%d",&n); 9 f[2]=f[3]=1;10 for(int i=4; i<=n; ++i) f[i]=f[i-2]+f[i-3];11 printf("%lld\n",f[n]);12 return 0;13 }14 15 int Aptal=Presist();16 int main(int argc,char*argv[]){;}
递推AC

 

转载于:https://www.cnblogs.com/Shy-key/p/7593659.html

你可能感兴趣的文章
mysql 下 计算 两点 经纬度 之间的距离 含具体sql语句
查看>>
SpringMVC_中文乱码的配置 --跟海涛学SpringMVC(和自己在项目中的实际使用的对比)...
查看>>
apache使用总结
查看>>
getopt、getopt_long 简介
查看>>
Linux eject 命令
查看>>
Python 常用函数
查看>>
作为布尔表达式的时候会被解释器当做False的值
查看>>
linux 网络编程:客户端与服务器通过TCP协议相互通信 + UDP
查看>>
程序人生之我们的故事:十年如歌(9)
查看>>
用户体验之“双语标签”
查看>>
IOS打包和发布简单介绍
查看>>
scp ssh 拷贝文件夹
查看>>
JavaScript学习05 定时器
查看>>
CSS
查看>>
Ubuntu 11.04安装GCC 4.6.1
查看>>
甲骨论
查看>>
C# 集合类-接口
查看>>
InstallShield Limited Edition for Visual Studio 2013 图文教程(教你如何打包.NET程序)
查看>>
基于visual Studio2013解决面试题之1004最长等差数列
查看>>
联系方式
查看>>