Half of and a Half

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1179    Accepted Submission(s): 539

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?
 
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;
 
Output
For every N inputed, tell how many chocolates Gardon had at first.
 
Sample Input
2
 
Sample Output
7
 
 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
int a[];
}s[];
int main()
{
int i,j,t,n;
s[].a[]=;
for(i=;i<=;i++)
{
int r=;
for(j=;j<;j++)
{
s[i].a[j]=s[i-].a[j]*+r; r=s[i].a[j]/; s[i].a[j]%=; }
t=;
while(s[i].a[t]+>)
{
s[i].a[t]=;
t++;
}
s[i].a[t]+=;
}
while(scanf("%d",&n)!=EOF)
{
for(i=;i>=,s[n].a[i]==;i--);
for(j=i;j>=;j--)
printf("%d",s[n].a[j]);
printf("\n"); }
return ;
}

HDU 1592 Half of and a Half(大数)的更多相关文章

  1. hdu 4099 Revenge of Fibonacci 字典树+大数

    将斐波那契的前100000个,每个的前40位都插入到字典树里(其他位数删掉),然后直接查询字典树就行. 此题坑点在于 1.字典树的深度不能太大,事实上,超过40在hdu就会MLE…… 2.若大数加法时 ...

  2. HDU 5351 MZL's Border (规律,大数)

    [HDU 5351 MZL's Border]题意 定义字符串$f_1=b,f_2=a,f_i=f_{i-1}f_{i-2}$. 对$f_n$的长度为$m$的前缀$s$, 求最大的$k$满足$s[1] ...

  3. HDOJ/HDU 1865 1sting(斐波拉契+大数~)

    Problem Description You will be given a string which only contains '1'; You can merge two adjacent ' ...

  4. hdu 5429 Geometric Progression(存个大数模板)

    Problem Description Determine whether a sequence is a Geometric progression or not. In mathematics, ...

  5. hdu 1002 A + B Problem II【大数加法】

    题目链接>>>>>> 题目大意:手动模拟大数加法,从而进行两个大数的加法运算 #include <stdio.h> #include <strin ...

  6. hdu 5666 Segment 俄罗斯乘法或者套大数板子

    Segment Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem ...

  7. HDU 1002 A + B Problem II (大数加法)

    题目链接 Problem Description I have a very simple problem for you. Given two integers A and B, your job ...

  8. hdu 5973 Game of Taking Stones(大数,bash game¥)

    Game of Taking Stones Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  9. hdu 1002 A + B Problem II(大数)

    题意:就是求a+b (a,b都不超过1000位) 思路:用数组存储 第一道大数的题目,虽然很水,纪念一下! 代码: #include<cstdio> #include<cstring ...

随机推荐

  1. MVC ---- 如何使用Predicate以及如何自定定义Predicate委托

    微软公司提供只能返回bool值,接受一个参数的委托类型(Predicate). //Predicate委托 public static class PredicateDemo{ //内置方法 publ ...

  2. ubuntu 16.04 kinetic 安装rosbridge

    sudo apt-get install ros-kinetic-rosbridge-server

  3. [IOS][sqlite][SQL][数据库]SQL基本语句大全

    参考:http://www.cnblogs.com/yubinfeng/archive/2010/11/02/1867386.html 一.基础 1.说明:创建数据库CREATE DATABASE d ...

  4. spring boot 开发 ajax返回值报错

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template "succeed", templ ...

  5. Linux中查看各文件夹大小(扫盘)

    df -h ./ du -hs ./ du -h /ifs4/BC_RD/USER/lizhixin/my_project/human_chr22 | grep [[:digit:]+]G du [- ...

  6. English trip -- VC(情景课)5 B Places around town 城市设施

    Vocabulary focus 核心词汇  drugstore  药店:    pill  n. 药丸:弹丸,子弹:口服避孕药         medicine  n. 药:医学:内科:巫术 hos ...

  7. Mac安装软件时 提示已损坏的解决方法

    进入终端: sudo spctl --master-disable

  8. 2018焦作网络赛Mathematical Curse

    题意:开始有个数k,有个数组和几个运算符.遍历数组的过程中花费一个运算符和数组当前元素运算.运算符必须按顺序花费,并且最后要花费完.问得到最大结果. 用maxv[x][y]记录到第x个元素,用完了第y ...

  9. Android设计模式之单例模式

    定义 单例模式是一种常用的软件设计模式.在它的核心结构中只包含一个被称为单例的特殊类.通过单例模式可以保证系统中一个类只有一个实例 . 单例模式是设计模式中最简单的形式之一.这一模式的目的是使得类的一 ...

  10. Html显示地图

    Html可以通过JS来实现第三方地图的显示,如: 高德: 效果如下:浏览器小区域和全屏展示 代码如下:把key换成自己申请的key值 <script type="text/javasc ...