奋斗的小蜗牛
时间限制:1000 ms | 内存限制:65535 KB
难度:1
- 描述
- 传说中能站在金字塔顶的只有两种动物,一种是鹰,一种是蜗牛。一只小蜗牛听了这个传说后,大受鼓舞,立志要爬上金字塔。为了实现自己的梦想,蜗牛找到了老鹰,老鹰告诉它金字塔高H米,小蜗牛知道一个白天自己能向上爬10米,但由于晚上要休息,自己会下滑5米。它想知道自己在第几天能站在金字塔顶,它想让你帮他写个程序帮助它。
- 输入
- 第一行有一个整数t,表示t组测试数据。
第二行一个整数H(0<H<10^9)代表金字塔的高度。 - 输出
- 输出一个整数n表示小蜗牛第n天站在金字塔顶上
- 样例输入
-
2 1 5
- 样例输出
-
1 1
import java.util.Scanner; public class Main28 { public static void main(String[] args) { Scanner input = new Scanner(System.in); while (input.hasNext()) { int num = input.nextInt(); for (int i = 0;i<num;i++) { int height = input.nextInt(); int day = 0; if (height <= 10) { day = 1; } else { if ((height-10)%5 != 0) { day = 1+(height-10)/5+1; } else { day=1+(height-10)/5; } } System.out.println(day); } } input.close(); } }