hdu 1592——Half of and a Half
来源:互联网 发布:c语言求1到n的和函数 编辑:程序博客网 时间:2024/05/16 01:15
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1592
题意:每遇到一个人,给他手中的巧克力和一个的半个,直到遇到Angel,最后自己手中没有巧克力,求他最初在market买了几块巧克力
解题思路:递推。数据太大,需要使用大整数加法
#include <stdio.h>#include <string.h>int s[100001];int main(){int n,i,j,l;while(scanf("%d",&n)!=-1){int flag=0;memset(s,0,sizeof(s));s[0]=1;l=1;while(n--){for(j=0;j<l;j++)s[j]*=2;for(j=0;j<l;j++){if(s[j]>=10){if(s[l-1]>=10)l++;s[j]-=10;s[j+1]++;}}s[0]++;}for(i=l-1;i>=0;i--)printf("%d",s[i]);printf("\n");}return 0;}
- hdu 1592——Half of and a Half
- hdu 1592 Half of and a Half(大数)
- HDU 1592 Half of and a Half(高精度)
- 杭电1592 Half of and a Half 大数
- 杭电1592Half of and a Half(大数)
- HDU1592-Half of and a Half
- WOJ1142-Half of and a Half
- 杭电OJ题 1592 Half of and a Half 解题报告
- STRHH - Half of the half
- Half Water and Half Fire
- Reverse Second Half of a Linked List
- C++的The Big Three and A Half 是什么
- just half cup of coffee
- just half cup of coffee
- 多线程设计模式——Half-sync/Half-async(半同步/半异步)模式
- Half-Sync/Half-Async
- (OK-HALF) To Find a Rogue DHCP Server—tcpdump/dhclient—nmap
- (OK-HALF) To Find a Rogue DHCP Server—tcpdump/dhclient—nmap
- 深入浅出K-Means算法
- C305例会-电脑攒机
- 对于ATMI编程同步请求与异步请求的需要注意的
- jsp中 java字符串比较用equals,不能用==
- usb的vid,pid
- hdu 1592——Half of and a Half
- 【hdu3037】【Lucas定理】Saving Beans
- Android: R cannot be resolved to a variable
- 查找 -数据结构
- Apache2配置代理服务器
- php cli命令 自定义参数传递
- mysql explain
- Part1:CException
- Spring + Quartz配置实例