hdu 2045 不容易系列之(3)—— LELE的RPG难题(递推)
来源:互联网 发布:mysql集群架构 编辑:程序博客网 时间:2024/05/08 22:30
题目分析:直接考虑,定义f[n]为 n位时,种类数,直接考虑f[n+1],如果第n与第一位相同,则f[n+1]=f[n-1]*2;
否则:f[n+1]=f[n]....则,f[n+1]=f[n]+f[n-1]*2;
初始化:f[1]=3 , f[2]=6, f[3]=6;
#include<iostream>#include<cstdio>using namespace std;int a[1000],b[1000],c[1000];int main(){__int64 f[60];f[1]=3;f[2]=6;f[3]=6; for(int i=4;i<=50;i++) f[i]=f[i-1]+f[i-2]*2;int n;while(scanf("%d",&n)!=EOF){ printf("%I64d\n",f[n]);} system("pasue"); return 0;}//递推式错了:开始以为是f[n]=f[n-1]*n,所以还写了一个类似求阶乘的算法......./*#include<iostream>#include<cstdio>using namespace std;int arr[1000];void function(int n){arr[1]=6;int c=1,temp;for(int i=4;i<=n;i++){temp=0; for(int j=1;j<=c;j++){ temp+=arr[j]*i;arr[j]=temp%10;temp/=10;}while(temp!=0){arr[++c]=temp%10;temp/=10;}}if(n%2==0){temp=arr[1]+6;arr[1]=temp%10;temp/=10;if(temp!=0) for(int i=2;i<=c;i++) { temp+=arr[i]; arr[i]=temp%10; temp/=10; if(temp==0) break; }if(temp!=0)arr[++c]=temp;}for(int i=c;i>=1;i--)printf("%d",arr[i]);printf("\n");}int main(){int f[4]={0,3,6,6};int n;while(scanf("%d",&n)!=EOF){if(n<4)printf("%d\n",f[n]);else{function(n);}}system("pause");return 0;}*/
- hdu 2045 不容易系列之(3)—— LELE的RPG难题(递推)
- HDU 2045 不容易系列之(3)——LELE的RPG难题【递推】
- hdu 2045 不容易系列之(3)—— LELE的RPG难题 (递推)
- hdu 2045不容易系列之(3)—— LELE的RPG难题(递推)
- HDU-2045 不容易系列之(3)—— LELE的RPG难题(递推)
- HDU 2045 不容易系列之(3)—— LELE的RPG难题 递推
- hdu 2045 不容易系列之(3)—— LELE的RPG难题(递推)
- HDU 2045--不容易系列之(3)—— LELE的RPG难题【递推】
- hdu 2045 递推 不容易系列之(3)—— LELE的RPG难题
- HDU 2045 不容易系列之(3)—— LELE的RPG难题 递推公式
- HDU 2045 不容易系列之(3)—— LELE的RPG难题(递推)
- 递推 HDU 2045 不容易系列之(3)—— LELE的RPG难题
- HDU 2045 不容易系列之(3)—— LELE的RPG难题 【递推】
- HDOJ题目2045 不容易系列之(3)—— LELE的RPG难题 (递推)
- 【暑期基础2】T HDU 2045 不容易系列之(3)—— LELE的RPG难题 (递推)
- 递推—杭电2045 不容易系列之(3)—— LELE的RPG难题
- HDUJ 2045 不容易系列之(3)—— LELE的RPG难题 递推
- HD 2045 递推 //不容易系列之(3)—— LELE的RPG难题
- c# 结构体struct包含数与byte类型的转换(一)
- 使用JDK1.6编译器API动态编译java源代码实例
- 杭电2003 求绝对值
- 避免内存泄露, 有效利用内存 !
- 内核编译 & 模块编译
- hdu 2045 不容易系列之(3)—— LELE的RPG难题(递推)
- openGL 函数能正常执行,但是没有结果,该怎么办?方法之一
- 电影 《遗愿清单》
- 解决AcroPro缺少msi文件的错误方法
- Install Maven 3 on Ubuntu 11.04
- struts2文件下载bug
- Android屏幕元素层次结构
- onMeasure和onLayout
- android上一些方法的区别和用法的注意事项