[hdoj]1143递归水题……可是我还没做出来……

 1 #include <stdio.h>
 2 #define MAX 31
 3 int a[MAX];
 4 int main() {
 5     int n;
 6     a[0] = 1;
 7     a[2] = 3;
 8     for(int i = 4; i< MAX; i = i+2)
 9         a[i] = 4*a[i-2] - a[i-4];
10     while(scanf("%d",&n)==1&&n!=-1)
11         printf("%d\n",a[n]);
12     return 0;
13 }  

递推 打表

时间: 2024-08-24 02:37:19

[hdoj]1143递归水题……可是我还没做出来……的相关文章

hdu 3342 Legal or Not 拓扑排序判断环。 现在的我,除了刷水题,,还能干什么

Legal or Not Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4960    Accepted Submission(s): 2270 Problem Description ACM-DIY is a large QQ group where many excellent acmers get together. It is

Uva10474-STL水题-白书

白书的一道水题.话说好久没认真做难题了.今天出了排名,所有队伍里倒数第一啊! 代码没什么可说的了. #include <algorithm> #include <cstring> #include <ctype.h> #include <cstdlib> #include <cstdio> #include <vector> #include <string> #include <queue> #include

POJ 2070 Filling Out the Team(水题)

[题目简述]:给出了球场上WideReceiver,Lineman,Quarterback三个位置所需人员的最低属性(speed,weight ,strength)要求,输入:三个数据,为别为speed.weight.strength,若输入的速度低于或等于球场上位置的要求,体重和力量大于或等于球场上位置的要求,则输出相应的符合位置,若有多个符合的位置,中间用一个空格隔开输出,如没有符合位置,则输出 No positions. [分析]:很简单,但是,对于我的代码还是有个疑问,就是拿题目中前两个

HDOJ 2317. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of

水题 HDOJ 4716 A Computer Graphics Problem

题目传送门 1 /* 2 水题:看见x是十的倍数就简单了 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #include <string> 9 #include <cmath> 10 using namespace std; 11 12 const int MAXN = 1e4 + 10; 13

水题 HDOJ 4727 The Number Off of FFF

题目传送门 1 /* 2 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #include <string> 9 #include <cmath> 10 using namespace std; 11 12 const in

poj水题-1579 将递归记录会变快

短平快递归肯定卡死,这里需要了解一个情况. 1.递归是否在很多情况再做重复工作? 2.由递归生成的“大面积数据”是否是由“小范围数据”组合而来? 如果都回答“是”.就强烈推荐“记笔记方式”.如果有笔记记录,那么查笔记,否则递归. #include <stdio.h> long s[21][21][21] = {0}; int w(int a,int b,int c) { if (a <= 0 || b <= 0 || c <= 0) return s[0][0][0]=1;

HDOJ/HDU 1256 画8(绞下思维~水题)

Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一个整数,字符表示画笔,整数(>=5)表示高度. Output 画横线总是一个字符粗,竖线随着总高度每增长6而增加1个字符宽.当总高度从5增加到6时,其竖线宽度从1增长到2.下圈高度不小于上圈高度,但应尽量接近上圈高度,且下圈的内径呈正方形. 每画一个"8"应空一行,但最前和最后都无空

HDOJ/HDU 2560 Buildings(嗯~水题)

Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, the green grids represent the buidings. Given the size of the HZNU Campus, and the color of each grid, you should count how many green grids in the N