poj 3077Rounders(模拟)
转载请注明出处: viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents
id=3077
Description
and so on ...
Input
Output
Note: Round up on fives.
Sample Input
9
15
14
4
5
99
12345678
44444445
1445
446
Sample Output
20
10
4
5
100
10000000
50000000
2000
500
代码一、例如以下:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int t, n, k, count;
char s[17];
int i, j;
while(cin >>t)
{
while(t--)
{
count = 0;
int p = 0, l = 0;;
memset(s,0,sizeof(s));
cin>>s;
int len = strlen(s);
if(len == 1)
{
cout<<s[0]<<endl;
continue;
}
for(i = len-1; i > 0; i--)
{
if(s[i]-'0'+p > 4)
{
p = 1;
count++;
}
else
{
p = 0;
count++;
}
}
if(s[0]-'0' + p > 9)
{
cout<<10;
}
else
{
cout<<s[0]-'0'+p;
}
for(i = 0; i < count; i++)
{
cout<<'0';
}
cout<<endl;
}
}
return 0;
}
代码二、例如以下:
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std; int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, count = 0;
scanf("%d", &n);
double x = n;
while (x >= 10)
{
x /= 10;
x = (int)(x + 0.5);
count++;
}
n = (int)x;
for (int i = 0; i < count; i++)
n *= 10;
printf("%d\n", n);
}
return 0;
}
poj 3077Rounders(模拟)的更多相关文章
- POJ 1016 模拟字符串
Numbers That Count Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 20396 Accepted: 68 ...
- POJ 1208 模拟
2017-08-28 15:07:16 writer:pprp 好开心,这道题本来在集训的时候做了很长很长时间,但是还是没有做出来,但是这次的话,只花了两个小时就做出来了 好开心,这次采用的是仔细分析 ...
- POJ - 3087 模拟 [kuangbin带你飞]专题一
模拟洗牌的过程,合并两堆拍的方式:使先取s2,再取s1:分离成两堆的方式:下面C张放到s1,上面C张到s2.当前牌型与第一次相同时,说明不能搜索到答案. AC代码 #include<cstdio ...
- Shuffle'm Up POJ - 3087(模拟)
Shuffle'm Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15249 Accepted: 6962 Des ...
- poj 1379 模拟退火法
/* 模拟退火法: 找到一些随机点,从这些点出发,随机的方向坐标向外搜索: 最后找到这些随机点的最大值: 坑://if(xx>-eps&&xx<x+eps&& ...
- POJ 1471 模拟?
题意:求最大无坏点三角形 思路: 模拟? (为什么我模拟过了...) 有人用 DP,有人用 搜索... // by SiriusRen #include <cstdio> #include ...
- POJ 1951 模拟
思路: 坑爹模拟毁我一生 给两组数据: 输入: YOURE TRAVELING THROUGH ANOTHER DIMENSION A DIMENSION NOT OF SIGHT. 输出: YR T ...
- POJ 2141 模拟
思路:字符串解密 啥都告诉你了 模拟就好 //By SiriusRen #include <cstdio> #include <cstring> using namespace ...
- POJ 2459 模拟
题意: 思路: 按照题意模拟即可 //By SiriusRen #include <cstdio> using namespace std; int c,f1,f2,d,xx,yy,vis ...
随机推荐
- (原创)基于MCU的频率可调,占空比可调的PWM实现(MCU,MCS-51/MSP430)
1.Abstract 做这个是受朋友之邀,用在控制电机转动的方面.他刚好在一家好的单位实习,手头工作比较多,无暇分身,所以找我帮忙做个模型.要求很明晰,PWM的频率在0~1KHz范围内,占空比 ...
- SQL Server 存储引擎-剖析Forwarded Records
我们都知道数据在存储引擎中是以页的形式组织的,但数据页在不同的组织形式中其中对应的数据行存储是不尽相同的,这里通过实例为大家介绍下堆表的中特有的一种情形Forwared Records及处理方式. 概 ...
- 安卓系统上安装.net运行时 mono runtime
感谢以下博主: ubuntu指南 http://dawndiy.com/archives/229/ img大小调整 http://zebinj.blog.163.com/blog/static/206 ...
- Wix 安装部署(五) Bootstrapper 捆绑安装
Wix的xml配置确实很费劲,忍不住有点像吐槽一下,前四篇完成的功能在Windows Installer中通过配置能很快的弄出来.可惜有很多加了锁的功能在InstallShield Limited E ...
- 创建一个简单的HTTP服务(自动查找未使用的端口)
var t = new Thread(new ThreadStart(() => { HttpListener listener = new HttpListener(); var prefix ...
- [游戏模版16] Win32 飞机射击 敌人追踪
>_<:AI introduction. >_<:According the plane position (nowX,nowY) relative to birds' pos ...
- We are doomed, and RPC does not help
第一种死法:Big ball of Mud 架构里最常用的反面案例是 big ball of mud.很大程度上可以说打格子,把复杂的系统拆解成小格子是架构师最重要的工作.这个小格子有很多种名字,比如 ...
- Gradle命令行黑魔法
毫无疑问,现在Gradle已经成为java世界最火的构建工具,风头已经盖过了冗余的ant,落后的maven.Gradle是以Groovy语言编写的一套构建脚本的DSL,由于Groovy语法的优雅,所以 ...
- Win10年度更新开发必备:VS2015 Update 3正式版下载汇总
微软在06月27日发布了Visual Studio 2015 Update 3 .在MSDN中微软也提供下载,而且MSDN的Visual Studio 2015 Update 3与官方免费下载的文件是 ...
- C语言实现二叉树-03版
我们亲爱的项目经理真是有创意,他说你给我写得二叉树挺好的: 功能还算可以:插入节点,能够删除节点: 可是有时候我们只是需要查找树的某个节点是否存在: 所以我希望你能够给我一个find功能: 还有就是, ...