首页 > 学院 > 开发设计 > 正文

uva 839 (Not so mobile)天平 ---递归输入

2019-11-06 06:14:06
字体:
来源:转载
供稿:网友

java的写法

import java.util.Scanner;public class Main {	static Scanner scan = new Scanner(System.in);	public static void main(String[] args) {		int T = scan.nextInt();		while(T--!=0){			if(solve(new M(0))){				System.out.PRintln("YES");			}else{				System.out.println("NO");			}			if(T!=0)System.out.println();		}	}	private static boolean solve(M w) {		M wl = new M(scan.nextInt());		M dl = new M(scan.nextInt());		M wr = new M(scan.nextInt());		M dr = new M(scan.nextInt());		boolean b1 = true,b2 = true;		if(wl.value==0)b1 = solve(wl);		if(wr.value==0)b2 = solve(wr);		w.value = wl.value+wr.value;		return b1&&b2&&wl.value*dl.value==wr.value*dr.value;	}		static class M{		public int value;		public M(int value){			this.value = value;		}	}}


上一篇:跟开涛学SpringMVC...

下一篇:导出excl

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表