CF99A.Help Far Away Kingdom

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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?

在一个遥远的王国里,住着国王、王子、鞋匠、裁缝以及其他许多市民。他们一直幸福地生活着,直到一群 ACMer 来到了这个王国。

这些奇怪生物给王国造成的最大损害,便是他们对高精度数字的痴迷。结果,王国的医师们已经三次约见了商人,要求他们出售恰好为 0.2735491070.273549107 桶啤酒这样的商品。为了以某种方式应对这一问题,国王颁布了一道命令,强制要求将所有数字四舍五入到最接近的整数,以简化计算。具体规定如下:

  • 若一个数的整数部分末位不为数字 9,且其小数部分严格小于 0.50.5,则该数向上取整后的结果即为其整数部分;
  • 若一个数的整数部分末位不为数字 9,且其小数部分不小于 0.50.5,则该数向上取整后的结果是将其整数部分的最后一位数字加 11;
  • 若一个数的整数部分末位为数字 9,则需前往寻求智者瓦西丽萨(Vasilisa the Wise)的帮助——在整个王国中,唯有她能执行向更高位进位的复杂运算。

商人们觉得该算法过于复杂,于是请求你们(ACMer)协助。你们能否编写一个程序,严格按照国王的命令完成四舍五入?

输入格式

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.

第一行包含一个需要向上取整的数字——整数部分(由一串非空的十进制数字组成,且不以 0 开头;但若该数字仅含一位数字,则允许以 0 开头),随后是一个字符 .(小数点),再随后是小数部分(任意非空的十进制数字序列)。该数字的总长度(包括小数点)不超过 1000 个字符。输入数据中不含其他任何字符。

输出格式

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).

如果整数部分的最后一位数字不等于 9,则输出向上取整后的数字(不带前导零);否则,输出消息 “GOTO Vasilisa.”(不带引号)。

输入输出样例

  • 输入#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.

输入解题思路,AI测评打分。不知道怎么写?

首页