A8231 | Help Far Away Kingdom
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly $0.273549107$ beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit $9$ and its fractional part is strictly less than $0.5$ , then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit $9$ and its fractional part is not less than $0.5$ , the rounded up number is obtained if we add $1$ to the last digit of the number’s integer part.
- If the number’s integer part ends with digit $9$ , to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly $0.273549107$ beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit $9$ and its fractional part is strictly less than $0.5$ , then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit $9$ and its fractional part is not less than $0.5$ , the rounded up number is obtained if we add $1$ to the last digit of the number’s integer part.
- If the number’s integer part ends with digit $9$ , to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
输入格式
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with $0$ — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed $1000$ characters, including the dot. There are no other characters in the input data.
输出格式
If the last number of the integer part is not equal to $9$ , print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
输入输出样例
输入 #1
0.0
输出 #1
0
输入 #2
1.49
输出 #2
1
输入 #3
1.50
输出 #3
2
输入 #4
2.71828182845904523536
输出 #4
3
输入 #5
3.14159265358979323846
输出 #5
3
输入 #6
12345678901234567890.1
输出 #6
12345678901234567890
输入 #7
123456789123456789.999
输出 #7
GOTO Vasilisa.
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted