http://acm.hdu.edu.cn/showproblem.php?pid=1250

大数斐波那契

%08d是什么东西,为什么我用flag交不上,唉,不刷大数了,没劲。暑假再讲。

就是交不上

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
int ta[][];
int main()
{
int n,k;
memset(ta,,sizeof(ta));
ta[][]=;
ta[][]=;
ta[][]=;
ta[][]=;
ta[][]=;
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
k=ta[i][j]+ta[i-][j]+ta[i-][j]+ta[i-][j]+ta[i-][j];
if(k>=)
{
ta[i][j+]=k/;
ta[i][j]=k%;
}
else ta[i][j]=k;
} }
while(scanf("%d",&n)!=EOF)
{
int i,j;
for(i=;i>=;i--)
if(ta[n][i]!=) break;
printf("%d",ta[n][i]);
for(j=i-;j>=;j--)
printf("%05d",ta[n][j]);//5个字符宽度的整数,不够5个的左边用0补齐
printf("\n");
}
return ;
}

http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2876

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
int ta[][];
int main()
{
int n,k;
memset(ta,,sizeof(ta));
ta[][]=;
ta[][]=;
ta[][]=;
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
k=ta[i][j]+ta[i-][j]+ta[i-][j];
if(k>=)
{
ta[i][j+]=k/;
ta[i][j]=k%;
}
else ta[i][j]=k;
} }
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
int i,j;
for(i=;i>=;i--)
if(ta[n][i]!=) break;
printf("%d",ta[n][i]);
for(j=i-;j>=;j--)
printf("%05d",ta[n][j]);//5个字符宽度的整数,不够5个的左边用0补齐
printf("\n");
}
return ;
}

Hat's Fibonacci的更多相关文章

  1. hdu 1250 Hat's Fibonacci

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1250 Hat's Fibonacci Description A Fibonacci sequence ...

  2. Hat's Fibonacci(大数,好)

    Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  3. Hat's Fibonacci(大数加法+直接暴力)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1250 hdu1250: Hat's Fibonacci Time Limit: 2000/1000 M ...

  4. (二维数组 亿进制 或 滚动数组) Hat's Fibonacci hdu1250

    Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  5. HDUOJ----1250 Hat's Fibonacci

    Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  6. HDU 1250 Hat's Fibonacci(大数相加)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1250 Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Ot ...

  7. HDU 1250 Hat's Fibonacci (递推、大数加法、string)

    Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  8. hdu 1250 Hat's Fibonacci(高精度数)

    //  继续大数,哎.. Problem Description A Fibonacci sequence is calculated by adding the previous two membe ...

  9. HDOJ/HDU 1250 Hat's Fibonacci(大数~斐波拉契)

    Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequen ...

  10. HDU1250:Hat's Fibonacci

    Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequen ...

随机推荐

  1. vim重复操作的宏录制

    在编辑某个文件的时候,可能会出现需要对某种特定的操作进行许多次的情况,以编辑下面的文件为例: ;==================================================== ...

  2. 使用私钥.pem和SecureCRT登陆linux系统

    将密钥上传到一台自己的linux主机,下面举例文件名为 key.pemchmod 600 key.pem改写密钥格式为 OpenSSH,如果询问passphrase可以留空(直接回车)ssh-keyg ...

  3. 改变presentModalView大小

    rc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; rc.modalPresentationStyle = UIModalP ...

  4. FPAG结构 组成 工作原理 开发流程(转)

    FPGA组成.工作原理和开发流程 备注:下面的描述基于ALTERA系列的FPGA芯片,而且是第一次学习FPGA,其中的一部分内容是参考一些资料总结的,个人独特的分析和见解还偏少. 1. FPGA概述 ...

  5. 【CF865C】Gotta Go Fast 二分+期望DP

    [CF865C]Gotta Go Fast 题意:有n个关卡需要依次通过,第i关有pi的概率要花ai时间通过,有1-pi的概率要花bi时间通过,你的目标是花费不超过m的时间通关,每一关开始时你都可以选 ...

  6. Spring注解及作用

    一: spring mvc中的@PathVariable是用来获得请求url中的动态参数的 @PathVariable用于方法中的参数,表示方法参数绑定到地址URL的模板: 例 @Controller ...

  7. CodeForces 832B Petya and Exam

    B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  8. hdu5266 pog loves szh III 【LCA】【倍增】

    Pog and Szh are playing games. Firstly Pog draw a tree on the paper. Here we define 1 as the root of ...

  9. poj3259 Wormholes【最短路-bellman-负环】

    While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole ...

  10. HDFS 命令深入浅出

    HDFS 命令深入浅出~ [root@neusoft-master ~]# hadoop dfs Usage: hadoop fs [generic options] [-appendToFile & ...