2956 排队问题

时间限制: 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

50分TLE代码存档:

 #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,ans;
void dfs(int x)
{
if(x==){
ans++;return ;
}
else if(x<&&x!=) return;
dfs(x-);
dfs(x-);
}
int main()
{
scanf("%d",&n);
dfs(n);
printf("%d",ans);
return ;
}

正解:

 #include<cstdio>
#define ll long long
using namespace std;
ll f[];
int main() {
int n;
scanf("%d", &n);
f[]=; f[]=f[]=;
for(int i=;i<=n;i++) f[i]=f[i-]+f[i-];
printf("%lld\n", f[n]);
return ;
}
// 这题居然是递推!!!!!!

最新文章

  1. mysql每秒最多能插入多少条数据 ? 死磕性能压测
  2. Ubuntu下tftp服务搭建
  3. HDU 4432 Sum of divisors (进制模拟)
  4. Egret HTTP网络
  5. android的task任务栈
  6. centos 彻底删除nodejs默认的安装文件
  7. wxWidgets+wxSmith版电子词典
  8. .Net2.0 --Winform结合WebBrowser控件和Socket老技术来实现另类Push~
  9. ZOJ 1011 - NTA
  10. JS 函数节流和去抖
  11. Python 安装包的导入
  12. 解决无法打开myeclipse--&gt;“The default workspace&#39;D: /myeclipse spaceis in use or cannot be created. Please choose a different one”
  13. 使用nginx做反向代理和负载均衡效果图
  14. Ajax(Asynchronous JavaScript )and xml
  15. linux下主从同步和redis的用法
  16. python pyMysql 自定义异常 函数重载
  17. Sql Server 查询库表记录数
  18. IDEA 2017 破解
  19. RabbitMQ双活实践(转)
  20. linux命令之系统管理命令(上)

热门文章

  1. Docker镜像的目录存储讲解
  2. Educational Codeforces Round 11 C hard process_补题——作为司老大的脑残粉
  3. Data truncation: Data too long for column &#39;id&#39; at row 1
  4. Python字符编码及字符串
  5. snprintf()返回值的陷阱
  6. swift中使用sqlite3
  7. HTML5 Canvas奇幻色彩Loading加载动画
  8. css布局--两列布局,左侧固定,右侧自适应(其中左侧要可以拖动,右侧水平滚动条)
  9. 几种优化web页面加载速度的策略
  10. 王小胖之 Base64编码/解码