D - Half of and a Half

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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<string.h>
using namespace std;
int ans[][];
int main()
{
//memset(ans,0,sizeof(ans));
int n,i,j;
while(scanf("%d",&n)!=EOF)
{ //i=300;
memset(ans,,sizeof(ans));
ans[]=;
while(n--)
{
int c=;
int s=; for(i=;i>=;i--)
{
if(i==)
s=ans[i]*++c;
else s=ans[i]*+c;
ans[i]=s%;
c=s/; }
}
for(i=;i<=;i++) if(ans[i]!=) break;
j=i;
for(j=i;j<=;j++) printf("%d",ans[j]);
printf("\n");
}
return ;
}

D - Half of and a Half 大数的更多相关文章

  1. BZOJ 3110: [Zjoi2013]K大数查询 [树套树]

    3110: [Zjoi2013]K大数查询 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 6050  Solved: 2007[Submit][Sta ...

  2. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  3. c语言经典算法——查找一个整数数组中第二大数

    题目: 实现一个函数,查找一个整数数组中第二大数. 算法思想: 设置两个变量max1和max2,用来保存最大数和第二大数,然后将数组剩余的数依次与这两个数比较,如果这个数a比max1大,则先将max1 ...

  4. 杨氏矩阵:查找x是否在矩阵中,第K大数

    参考:http://xudacheng06.blog.163.com/blog/static/4894143320127891610158/ 杨氏矩阵(Young Tableau)是一个很奇妙的数据结 ...

  5. 蓝桥杯算法提高 P1001(大数乘法)

      算法提高 P1001   时间限制:1.0s   内存限制:256.0MB   当两个比较大的整数相乘时,可能会出现数据溢出的情形.为避免溢出,可以采用字符串的方法来实现两个大数之间的乘法. 具体 ...

  6. 51nod 1005 大数加法

    #include<iostream> #include<string> using namespace std; #define MAXN 10001 },b[MAXN]={} ...

  7. PHP大数(浮点数)取余

    一般我们进行取余运算第一个想到的就是用百分号%,但当除数是个很大的数值,超出了int范围时,这样取余就不准确了. php大数(浮点数)取余函数 /** * php大数取余 * * @param int ...

  8. HDU 5686 斐波那契数列、Java求大数

    原题:http://acm.hdu.edu.cn/showproblem.php?pid=5686 当我们要求f[n]时,可以考虑为前n-1个1的情况有加了一个1. 此时有两种情况:当不适用第n个1进 ...

  9. 区间K 大数查询

      算法训练 区间k大数查询   时间限制:1.0s   内存限制:256.0MB 问题描述 给定一个序列,每次询问序列中第l个数到第r个数中第K大的数是哪个. 输入格式 第一行包含一个数n,表示序列 ...

  10. HDU 5047 Sawtooth(大数优化+递推公式)

    http://acm.hdu.edu.cn/showproblem.php?pid=5047 题目大意: 给n条样子像“m”的折线,求它们能把二维平面分成的面最多是多少. 解题思路: 我们发现直线1条 ...

随机推荐

  1. sqlserver 纵横

    纵表转横表 create table Score ( Name ), Class ), score int ) ) ) ) ) ) ) ) select * from Score select t.N ...

  2. 微软 WP 新策略:非开发者账号免费解锁 1 部手机(转)

    好消息,微软现在非开发者用户解锁1部WP8手机和部署两个应用,即我们只 需注册个windows live账号即可解锁我们的WP8了!! 准备工作:1.需要一台装有windows8 64位系统的电脑. ...

  3. SQL 向上取整、向下取整、四舍五入取整的实例!round、rounddown、roundup

    sql server ==================================================== [四舍五入取整截取] select round(54.56,0) === ...

  4. Zero Copy

    原文出处: http://www.ibm.com/developerworks/library/j-zerocopy/ 传统的I/O 使用传统的I/O程序读取文件内容, 并写入到另一个文件(或Sock ...

  5. KDE、GNOME 和 XFCE 桌面比较

    KDE.GNOME 和 XFCE 桌面比较   这么多年来,很多人一直都在他们的 linux 桌面端使用 KDE 或者 GNOME 桌面环境.在这两个桌面环境多年不断发展的同时,其它的桌面也在持续增加 ...

  6. velocity常用语句速查表

    velocity常用语句 * 变量定义 #set($directoryRoot = "www" ) * #if($!list.size() != 0) //判断list不为空 #f ...

  7. Security » Authorization » 基于角色的授权

    Role based Authorization¶ 基于角色的授权 133 of 153 people found this helpful When an identity is created i ...

  8. bootstrap笔记-布局

    1.通过文本对齐类,可以简单方便的将文字重新对齐. <p class="text-left">Left aligned text.</p> <p cl ...

  9. MPICH3 配置安装问题列表

    问题列表 1: configure: error: F90 and F90FLAGS are replaced by FC and FCFLAGS respectively in this confi ...

  10. 用OPencv配置vs2010

    第一次作业,图像的识别存储和显示 此次选用的是Microsoft Visual Studio 2010软件,在配置和opencv的时候,要选好版本苟泽造成不兼容,因此我选用的为opencv 2.4.1 ...