大数乘法    不会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. 面试之SQL(2)--left join, inner join 和 right join的区别

    表A记录如下: aID        aName 1           a1 2           a2 3           a3 4           a4 5           a5 ...

  2. 使用zipalign.exe工具优化APK安装包

    zipalign.exe是Android自带的一个档案整理工具,它可以用于优化APK安装包,从而提升Android应用与系统之间的交互效率,提升应用程序的运行速度. 操作步骤: 1.在命令行窗口输入如 ...

  3. ubuntu(16.04.01)学习-day2--高级命令

    1.查找命令 find -name "hello.c" grep "test" grep "usb" -c -r /drivers/usb ...

  4. PSP个人软件开发工具需求分析文档

    第一部分:前景与范围 1.业务需求 1.1 背景 在目前的软件项目开发过程中,进度计划总是非常不准确,经常出现延期,而且大多数都无法给出一个相对比较准确的延迟时间.即使使用用例包.用例的方式组织需求, ...

  5. 如何在UINavigationBar上添加UISearchBar以及UISearchDisplayController的使用 --OC --iOS

    那我们开始吧,下面是Sely写的一个Demo,分享给大家. 新建一个项目, UISearchDisplayController 的 displaysSearchBarInNavigationBar太死 ...

  6. phpmyadmin安装教程及配置设置

    phpmyadmin安装教程及配置设置 | 浏览:20304 | 更新:2013-11-07 09:50 1.一般网上下载到的phpmyadmin是一个压缩包,我们将其释放到htdocs目录中,例如h ...

  7. linux file命令小记

    在linux中,所有东西都是文件:而且他并没有后缀名这一概念.Linux的扩展名没有太大的意义, file.tar.gz file.tgz file.tar.bz2 file.rar file.gz ...

  8. md5值计算

    1.md5(Message Digest 5th/消息概要加密算法 第5版) REFER: MD5 On wikipedia 2.应用范围 ① 验证下载文件的完整性 ② 3.关于MD5的几个问题 ①只 ...

  9. [Guava学习笔记]Basic Utilities: Null, 前置条件, Object方法, 排序, 异常

    我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3842433.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...

  10. 学习笔记--Quartz定时器

    文章同步发表在博主网站朗度云,传输门:http://www.wolfbe.com/detail/201608/338.html 1.Quartz定时器执行流程 Quartz需要定义执行任务.触发器,在 ...