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. STL_算法_02_排序算法

    ◆ 常用的排序算法: 1.1.合并(容器A(全部/部分)&容器B(全部/部分)==>容器C(全部/部分),容器C中元素已经排好顺序),返回的值==>iteratorOutBegin ...

  2. Codeforces 913D - Too Easy Problems

    913D - Too Easy Problems 思路:二分check k 代码: #include<bits/stdc++.h> using namespace std; #define ...

  3. Java 集合-集合介绍

    2017-10-30 00:01:09 一.Java集合的类关系图 二.集合类的概述 集合类出现的原因:面向对象语言对事物的体现都是以对象的形式,所以为了方便对多个对象的操作,Java就提供了集合类. ...

  4. C#获取类库(DLL)的绝对路径

    C#中当我们在写公共的类库的时候难免会调用一些xml配置文件,而这个配置文件的路径则非常重要,常用的方式就是写在web.config中,而我们也可以将配置文件直接放在dll的同级目录,那么怎么获得当前 ...

  5. 新概念 Lesson 4 Are you a teacher

    打招呼用语: Good morning, Good afternoon,Good evening Nice to meet you. How do you do? She is French. 她是法 ...

  6. 3-4 8精彩算法集合。struct(C,ruby) Ruyb类对象和结构体, 3-5

    在本章我遇到了c语言的struct数据,即自定义的数据结构.比如: struct edge { int u; int v; int w; }; 题目给了一组数据,用edge储存.需要按照w大小排序.我 ...

  7. python-day46--前端基础之html

    一.html是什么? 超文本标记语言(Hypertext Markup Language,HTML)通过标签语言来标记要显示的网页中的各个部分.一套规则,浏览器认识的规则 浏览器按顺序渲染网页文件,然 ...

  8. 利用nodeJs anywhere搭建本地服务器环境

    1.npm install anywhere -g 如果是mac系统会提示你权限不够,需要在代码前加上 sudo获取管理员权限.即sudo npm install anywhere -g. 2.安装完 ...

  9. Leetcode 74

    class Solution { public: bool searchMatrix(vector<vector<int>>& matrix, int target) ...

  10. 无法使用BIPublisher开发报表

    我的机器是windows7,word版本问word 2010 32bit. 以前BIPublisher(安装的是BIPublisher 10.1.33版本)能正常使用,突然有一天再想使用他的时候,报以 ...