大数乘法    不会java   比赛的时候各种细节RE  WA  ........

#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std;
int un[] = {0,0,0,0,0,1,3,6,13,26,52,104,208,416,833,1667,3335,6700};
int a[10010],b[10010],c[10010],ca;
void cc()
{
int w = 0;
memset(c, 0, sizeof(c));
for(int i = 0; i <= un[ca]; i++)
{
for(int j = 0; j <= un[ca]; j++)
{
c[i+j] += a[i]*b[j];
if(c[i+j] > 9999)
{
w = c[i+j]/10000;
c[i+j+1] += w;
c[i+j] %= 10000;
}
}
}
w = 0;
for(int i = 0; i <= un[ca]; i++)
{
c[i] += w;
w = c[i]/10000;
c[i] %= 10000;
}
memcpy(a, c, sizeof(c));
c[0] += 1;
memcpy(b, c, sizeof(c));
}
int main()
{
int n;
scanf("%d",&n);
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
a[0] = 1;
b[0] = 2;
ca = 0;
for(int i = 0; i < n; i++)
{
int j;
for(j = un[ca]; j >= 0; j--)
{
if(b[j])
break;
}
//printf("%d\n",j);
printf("%d",b[j--]);
for(; j >= 0; j--)
{
printf("%.4d",b[j]);
}
putchar('\n');
if(i == n-1)
break;
cc();
ca++;
}
return 0;
}

ural 1108的更多相关文章

  1. URAL 1108 简单的树形dp背包问题

    题目大意: 一颗苹果树上,每条边都对应了一个权值,最后留下包括root : 1在的含有 m 条边的子树 , 希望留下的子树中权值之和最大 这里保留m条边,我们可以看作是保留了 m + 1 个点 令dp ...

  2. NOIopenjudge 407:Heritage

    总时间限制:  5000ms 内存限制:  65536kB 描述 Your rich uncle died recently, and the heritage needs to be divided ...

  3. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  4. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  5. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  6. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  7. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  8. ural 2068. Game of Nuts

    2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...

  9. ural 2067. Friends and Berries

    2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...

随机推荐

  1. ViewPager的基本使用--可左右循环切换也可自动切换

    ViewPager也算是Android自带的常用控件之一,但是有可能会无法直接调用,所以只需要将工程目录里/libs/android-support-v4.jar该jarAdd to Build Pa ...

  2. Oracle 一些操作

    Achivelog ============================ alter system set db_recovery_file_dest='F:\ORACLE\recovery_ar ...

  3. OpenGL4-绘制旋转的立方体

    代码下载 #include "CELLWinApp.hpp"#include <gl/GLU.h>#include <assert.h>#include & ...

  4. javascript笔记——jQuery插件开发的几种方式

    jQuery插件开发分为两种: 1 类级别  类级别你可以理解为拓展jquery类,最明显的例子是$.ajax(...),相当于静态方法. 开发扩展其方法时使用$.extend方法,即jQuery.e ...

  5. UML建模文章总结

    一.为什么要学习UML UML是Unified Modeling Language(统一建模语言)的简称.UML是对软件密集型系统中的制品进行可视化.详述.构造和文档化的语言.制品{Artifact} ...

  6. gdb/valgrind/coredump to debug c/cpp program

    gdb/valgrind/coredump 调试 1.gdb 调试 while/for 循环 ①如果在调试 while/for的时候,可以用until xxx(其中,xxx代表 行号)直接跳转到循环后 ...

  7. Access数据库一种树形结构的实现和子节点查询

    BOOL CManageDataBase::GetDepTreeAllSons( int rootItem ) { CADORecordset Rst(&m_DataBase); BOOL b ...

  8. bzoj 1005 HNOI2008 明明的烦恼

    这题做的我欲哭无泪啊…… 我已经没心情多说啥了…… 高精度T啊!我太弱啊!改了一天啊!还不如滚粗啊! 想好式子在写啊! 能用高精度乘单精度就不要用高精度乘高精度啊!     能用高精度除单精度就不要用 ...

  9. java基础-基础类型包装类型

    想要对基本类型数据进行更多的操作,最方便的方式就是将其封装成对象. 为啥呢?因为在对象描述中就可以定义更多的属性和行为对该基本数据类型进行操作. [八种基本数据类型的包装类] byte --Byte ...

  10. CentOs Linux 分区建议

    硬盘分区方案 在计算机上安装Linux系统,对硬盘进行分区是一个非常重要的步骤,下面介绍几个分区方案. (1)方案1(桌面)/boot:用来存放与Linux系统启动有关的程序,比如启动引导装载程序等, ...