HDU1592(递推+大数处理)
来源:互联网 发布:windows apache php7 编辑:程序博客网 时间:2024/06/08 04:26
Half of and a Half
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 792 Accepted Submission(s): 350
Problem Description
Gardon bought many many chocolates from the A Chocolate Market (ACM). When he was on the way to meet Angel, he met Speakless by accident.
"Ah, so many delicious chocolates! I'll get half of them and a half!" Speakless said.
Gardon went on his way, but soon he met YZG1984 by accident....
"Ah, so many delicious chocolates! I'll get half of them and a half!" YZG1984 said.
Gardon went on his way, but soon he met Doramon by accident....
"Ah, so many delicious chocolates! I'll get half of them and a half!" Doramon said.
Gardon went on his way, but soon he met JGShining by accident....
"Ah, so many delicious chocolates! I'll get half of them and a half!" JGShining said.
.
.
.
After had had met N people , Gardon finally met Angel. He gave her half of the rest and a half, then Gardon have none for himself. Could you tell how many chocolates did he bought from ACM?
"Ah, so many delicious chocolates! I'll get half of them and a half!" Speakless said.
Gardon went on his way, but soon he met YZG1984 by accident....
"Ah, so many delicious chocolates! I'll get half of them and a half!" YZG1984 said.
Gardon went on his way, but soon he met Doramon by accident....
"Ah, so many delicious chocolates! I'll get half of them and a half!" Doramon said.
Gardon went on his way, but soon he met JGShining by accident....
"Ah, so many delicious chocolates! I'll get half of them and a half!" JGShining said.
.
.
.
After had had met N people , Gardon finally met Angel. He gave her half of the rest and a half, then Gardon have none for himself. Could you tell how many chocolates did he bought from ACM?
Input
Input contains many test cases.
Each case have a integer N, represents the number of people Gardon met except Angel. N will never exceed 1000;
Each case have a integer N, represents the number of people Gardon met except Angel. N will never exceed 1000;
Output
For every N inputed, tell how many chocolates Gardon had at first.
Sample Input
2
Sample Output
7
递推+大数处理
#include<iostream>
using namespace std;
int a[100];
int main()
{
int n,i,j,temp;
int len;
while(scanf("%d",&n)!=EOF)
{
memset(a,0,sizeof(a));
len=0;
a[len]=1;
for(i=1;i<=n;i++)
{
temp=0;
for(j=0;j<=len;j++)
{
if(j==0)
a[j]=(a[j]+0.5)*2;
else a[j]=a[j]*2+temp;
temp=a[j]/10000;
a[j]=a[j]%10000;
}
if(temp)
{
len++;
a[len]=temp;
}
}
printf("%d",a[len]);
for(i=len-1;i>=0;i--)
printf("%04d",a[i]);
printf("\n");
}
return 0;
}
- HDU1592(递推+大数处理)
- 大数递推
- poj2506 大数递推
- 大数+递推
- UVA11375 递推+大数
- SOJ 2209 递推 大数
- HDU 1041(递推+大数)
- UVA11375火柴(递推+大数)
- 2506Tiling(大数递推)
- poj 2506 递推+大数
- Tiling(递推、大数相加)
- 大数加法(递推)
- 大菲波数(递推 + JAVA大数)
- POJ 1090 Chain 递推 + 大数加法
- HDU 1041 递推 + 大数模板
- hdu1297Children’s Queue(递推+大数)
- [原][译]大数递推_HDU1297
- POJ 2506 Tiling ( 递推 + 大数 )
- hadoop学习笔记(四)Wrong FS报错
- 单纯形法
- CDN(内容分发网络)技术原理
- Datepicker-for-Bootstrap 日期选择插件
- Struts2文件上传大小限制
- HDU1592(递推+大数处理)
- 给图的顶点着色
- 汇编排序知识之冒泡排序
- 使用gdb调试多线程程序总结
- C++中struct和class的区别
- hadoop学习笔记(五) java heap space报错
- 简单的暴力搜索
- java------关键字使用
- nodejs json格式转换