解题思路:
似乎是贪心?
参考代码:
import java.util.Scanner; public class Main1108 { //速度 和 魔法消耗 static int SPEND = 17; static int m = 10; public static void main(String[] args) { Scanner sc = new Scanner(System.in); //魔法初始值 int M = sc.nextInt(); //距离 int S = sc.nextInt(); //最终下降的时间 int T = sc.nextInt(); int flash = 0; int distance = 0; for (int i = 1; i <= T; i++) { if (M >= 10) { M -= m; flash += 60; } else { M += 4; } distance = Math.max(distance + SPEND, flash); if (distance >= S) { System.out.println("Yes"); System.out.print(i); return; } } System.out.println("No"); System.out.print(distance); } }
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:619 |
C语言训练-计算一个整数N的阶乘 (C语言代码)浏览:936 |
不容易系列2 (C语言代码)浏览:597 |
printf基础练习2 (C语言代码)浏览:943 |
【偶数求和】 (C语言代码)浏览:646 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:1007 |
WU-图形输出 (C++代码)浏览:802 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:1341 |
Minesweeper (C语言描述,蓝桥杯)浏览:1127 |
出圈】指针malloc版浏览:355 |