当前位置:网站首页>Niuke's height in the 52nd monthly race B (thinking problem simulation problem)
Niuke's height in the 52nd monthly race B (thinking problem simulation problem)
2022-06-22 21:46:00 【GHOSTANDBREAD】
B- Niuniu's height _ Niuke Xiaobai moon race 52 (nowcoder.com)
Title Description
Niu Niu :“ You lower me 4.86 centimeter , After rounding, it is 4.9 centimeter , After rounding off, it is 5 centimeter , After rounding off, it is 10 centimeter !”
We know , Niuniu cares about his height , So he wants you to help him find out the maximum height after rounding , To simplify the problem , We think Niuniu's height is a positive integer .
“ rounding ”: This means that you can round any number of times in any bit in any order , Such as the :14861 -> 14900 -> 15000 -> 20000 .
Input description :
The first line is an integer TTT Represents the number of case groups .
Next TTT Each row is an integer nnn Stands for the height of Niuniu ( Zoom in properly ).
Guarantee :
1≤T≤103; 1≤n≤106;1\leq T \leq 10^3;\ \ 1 \leq n \leq 10^6;1≤T≤103; 1≤n≤106;
Output description :
The output, TTT That's ok , A positive integer in each line represents the result of rounding to maximize your height .
Example 1
Input
5 1 2038 99999 13453 32921
Output
1 2040 100000 14000 33000
explain
about 13453 This data , The change is like this :
13453 --> 13500
13500 --> 14000
Ideas :
Simulate according to the law of rounding
Code :
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int t;
vector<int> v;
int main() {
ios::sync_with_stdio(false);
cout.tie(nullptr);
cin >> t;
while(t --) {
int x;
cin >> x;
v.clear();
while(x) {
v.push_back(x % 10);
x /= 10;
}
reverse(v.begin(), v.end());
for(int i = v.size() - 1; i > 0; i --) {
if(v[i] >= 5) {
for(int j = i; j < v.size(); j ++) {
v[j] = 0;
}
v[i - 1] += 1;
}
}
if(v[0] >= 5) {
for(int j = 0; j < v.size(); j ++) {
v[j] = 0;
}
cout << 1;
}
for(int i = 0; i < v.size(); i ++) {
cout << v[i];
}
cout << "\n";
}
return 0;
}
边栏推荐
- 牛客 52次月赛 B牛牛的身高 (思维题 模拟题)
- 2022危险化学品经营单位主要负责人上岗证题库及模拟考试
- 杰理之在music模式下提示音使用打断模式无法播放的问题【篇】
- Lesson 031: permanent storage: pickle a jar of delicious pickles | after class test questions and answers
- 第031讲:永久存储:腌制一缸美味的泡菜 | 课后测试题及答案
- 引入稀疏激活机制!Uni-Perceiver-MoE显著提升通才模型的性能
- 第029讲:文件:一个任务 | 课后测试题及答案
- CVPR2022 | 海德堡大学《深度视觉相似性与度量学习》教程
- 基于C语言开发工资管理系统 课程论文+源码及可执行exe文件
- [redis]redis6 transaction operations
猜你喜欢

杰理之开启四声道通话近端变调问题【篇】

基于C语言开发工资管理系统 课程论文+源码及可执行exe文件

NFT,只可远观不可亵玩焉

Lesson 029: Documents: a task? After class test questions and answers

Laravel+ pagoda planning task

Lesson 026: Dictionary: when the index is not easy to use 2 | after class test questions and answers

2022化工自动化控制仪表考试练习题及在线模拟考试
![Jerry's dynamic switching EQ document [chapter]](/img/2d/9a0245b87fb05ea61dbfc7922ea766.png)
Jerry's dynamic switching EQ document [chapter]

2022年起重机械指挥考试模拟100题及模拟考试

不同网络结构的特征也能进行对比学习?蚂蚁&美团&南大&阿里提出跨架构自监督视频表示学习方法CACL,性能SOTA!
随机推荐
90- review of several recently optimized Oracle databases
Lesson 033: exception handling: you can't always be right 2 | after class test questions and answers
TC397 Flash
Lesson 016: sequence | after class test questions and answers
513. find the value in the lower left corner of the tree / Sword finger offer II 091 Paint the house
《跟唐老师学习云网络》 - OpenStack网络实现
Lesson 032: exception handling: you can't always be right | after class test questions and answers
Lesson 022: function: recursion is god horse after class test questions and answers
es 按条件查询数据总条数
Five uses of 87 with as
Jerry's music mode obtains the directory of playing files [chapter]
List of outstanding talents: no crystal vibration, one drag, eight burn and upgrade [chapter]
杰理之外挂 4M 的 flash 在 PC 上查看大小只有 1M 的处理方法【篇】
Learning cloud network from teacher Tang - openstack network implementation
2022化工自动化控制仪表考试练习题及在线模拟考试
[redis]redis persistence
CVPR2022 | 海德堡大学《深度视觉相似性与度量学习》教程
微信小程序批量提交审核
300. 最长递增子序列 ●●
2022年A特种设备相关管理(电梯)考题及模拟考试