D - Half of and a Half 大数
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
"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
Each case have a integer N, represents the number of people Gardon met except Angel. N will never exceed 1000;
Output
Sample Input
Sample Output
#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 大数的更多相关文章
- BZOJ 3110: [Zjoi2013]K大数查询 [树套树]
3110: [Zjoi2013]K大数查询 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 6050 Solved: 2007[Submit][Sta ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- c语言经典算法——查找一个整数数组中第二大数
题目: 实现一个函数,查找一个整数数组中第二大数. 算法思想: 设置两个变量max1和max2,用来保存最大数和第二大数,然后将数组剩余的数依次与这两个数比较,如果这个数a比max1大,则先将max1 ...
- 杨氏矩阵:查找x是否在矩阵中,第K大数
参考:http://xudacheng06.blog.163.com/blog/static/4894143320127891610158/ 杨氏矩阵(Young Tableau)是一个很奇妙的数据结 ...
- 蓝桥杯算法提高 P1001(大数乘法)
算法提高 P1001 时间限制:1.0s 内存限制:256.0MB 当两个比较大的整数相乘时,可能会出现数据溢出的情形.为避免溢出,可以采用字符串的方法来实现两个大数之间的乘法. 具体 ...
- 51nod 1005 大数加法
#include<iostream> #include<string> using namespace std; #define MAXN 10001 },b[MAXN]={} ...
- PHP大数(浮点数)取余
一般我们进行取余运算第一个想到的就是用百分号%,但当除数是个很大的数值,超出了int范围时,这样取余就不准确了. php大数(浮点数)取余函数 /** * php大数取余 * * @param int ...
- HDU 5686 斐波那契数列、Java求大数
原题:http://acm.hdu.edu.cn/showproblem.php?pid=5686 当我们要求f[n]时,可以考虑为前n-1个1的情况有加了一个1. 此时有两种情况:当不适用第n个1进 ...
- 区间K 大数查询
算法训练 区间k大数查询 时间限制:1.0s 内存限制:256.0MB 问题描述 给定一个序列,每次询问序列中第l个数到第r个数中第K大的数是哪个. 输入格式 第一行包含一个数n,表示序列 ...
- HDU 5047 Sawtooth(大数优化+递推公式)
http://acm.hdu.edu.cn/showproblem.php?pid=5047 题目大意: 给n条样子像“m”的折线,求它们能把二维平面分成的面最多是多少. 解题思路: 我们发现直线1条 ...
随机推荐
- html里的添加视频特效(美化,丰富内容)
现在如果要在页面中使用video标签,需要考虑三种情况,支持Ogg Theora或者VP8(如果这玩意儿没出事的话)的(Opera.Mozilla.Chrome),支持H.264的(Safari.IE ...
- Oracle求连续的年份
SELECT ('2013') + ROWNUM year FROM dualCONNECT BY ROWNUM <= 2;
- Beaglebone Black–I2C 接 BMP280 获取当前温度
我有两个含温度传感的模块,一个是AOSONG 奥松电子的 AM2320 温度湿度,另一个是九轴里面的 Bosch BMP280.由于 AM2320 用 I2C MODBUS,直接用 I2C Tools ...
- Sprint(第四天11.17)
燃尽图
- linux python pip包安装
python -m pip install --trusted-host pypi.python.org
- OSG开发概览
1 OSG基础知识 Ø OSG是Open Scene Graphic 的缩写,OSG于1997年诞生于以为滑翔机爱好者之手,Don burns 为了对滑翔机的飞行进行模拟,对openGL的库进行了封 ...
- USACO2011Brownie Slicing巧克力蛋糕切片
Description Bessie烘焙了一块巧克力蛋糕.这块蛋糕是由R*C(1 <= R,C <= 500)个小的巧克力蛋糕组成的. 第i行,第j列的蛋糕有N_ij(1 < ...
- shader函数
Intrinsic Functions (DirectX HLSL) The following table lists the intrinsic functions available in HL ...
- Linux系统下Apache2.4.17的安装过程
Linux系统下安装Apache Server2.4.17.还是先声明一下,Linux命令我不进行讲解,因为我不是讲Linux命令的.有需要注意的地方,我会上图,没什么值得的注意的地方,我就不上图了. ...
- rebuild new environment for DW step
Steps to rebuild PPE environment: (CTS) 1, Disable both CTS Daily Job (Daily) and CTS Daily Job (Sta ...