酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

chuck 酷爱数学,最近新学了一个公式 1/x+1/y=1。目前已知 x ,现在需要求解 y 。 输入格式: 第一行一个正整数 x(2<=x<=10 5 ) ,含义如上。 输出格式: 一个小数,表示 y 的具体值(保留小数点两位)

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int x = scanner.nextInt(); double y = (double) x / (x - 1); System.out.printf("%.2f", y); } } [2024-10-29 13:35:06 | AI写代码神器 | 73点数解答]

相关提问