nyoj1138 The number of maximum subset 递推
来源:互联网 发布:apache禁止访问根目录 编辑:程序博客网 时间:2024/06/05 13:51
题目链接~传送门
题目大意:no two elements in the subset should be adjacent
it shouldn't be possible to add numbers to the subset without violating the first condition
求最大的子集的个数
解题思路:
123456111 31 31 3 51 3 5 2222 42 42 4 6 1 42 51 3 6 1 42 5 1 4 6有对比可看出,f(n)是由f(n-2)和f(n-3) 递推过来的
所以可得代码
#include<stdio.h>int main(){ int n; int a[100]; a[1]=1;a[2]=2;a[3]=2; for(int i=4;i<77;i++) a[i]=a[i-3]+a[i-2]; while(scanf("%d",&n)!=EOF) printf("%d\n",a[n]);}
0 0
- nyoj1138 The number of maximum subset 递推
- 递推-nyoj-The number of maximum subset
- 大二第二次月赛--The number of maximum subset
- #poj2699 The Maximum Number of Strong Kings
- poj2699 The Maximum Number of Strong Kings
- Find the number of subsets such that the sum of numbers in the subset is a prime number
- POJ 2699 The Maximum Number of Strong Kings
- Increasing the maximum number of tcp/ip connections in linux
- poj 2699 The Maximum Number of Strong Kings
- poj 2699 The Maximum Number of Strong Kings 网络流
- LINUX AND THE MAXIMUM NUMBER OF PROCESSES (THREADS)
- POI: The maximum number of cell styles was exceeded.
- POJ 2699 The Maximum Number of Strong Kings(最大流)
- 解题报告 之 POJ2699 The Maximum Number of Strong Kings
- POJ 2699 The Maximum Number of Strong Kings
- POJ 2699The Maximum Number of Strong Kings(最大流)
- POJ2699 The Maximum Number of Strong Kings (maxflow)
- POJ 2699 The Maximum Number of Strong Kings 最大流
- 结构体
- hdu 1232 畅通工程(图中无回路)
- 最小序列-- LCA
- poj 1952 BUY LOW, BUY LOWER dp
- how happy how comes
- nyoj1138 The number of maximum subset 递推
- 论文笔记:《LSDA: Large Scale Detection Through Adaptation》(NIPS2014)
- LeetCode 154题:Count and Say
- hdu 1003 最大最长子序列 dp
- [yii]初步认识 建立第一个 Yii 应用
- android 支付宝SDK集成
- |打开对话框最大化显示|
- 条款03-06
- 第十一周程序填充星号图(一)