对决

xiaoxiao2021-02-28  106

对决

时间限制: 1000 ms  |  内存限制: 65535 KB 难度: 0 描述

Topcoder 招进来了 n 个新同学,Yougth计划把这个n个同学分成两组,要求每组中每个人必须跟另一组中每个同学进行一次算法对决,问存不存在一种分组方式在k场完成对决。(两组中每一组中人数都要大于0)

输入 有多组测试数据,每组测试数据两个数 n 和 k ,n和k都为0时表示输入结束。(0<n<10000,0<k<1000000) 输出 输出一行,如果可以,输出YES,不行的话输出NO。 样例输入 4 1 4 3 4 4 2 1 3 3 0 0 样例输出 NO YES YES YES NO

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int people=scanner.nextInt(); int number=scanner.nextInt(); while(people!=0 && number!=0) { String string=""; for(int i=1;i<=people;i++) { if(number==i*(people-i)) string="YES"; } if(!string.equals("YES")) string="NO"; System.out.println(string); people=scanner.nextInt(); number=scanner.nextInt(); } } }

转载请注明原文地址: https://www.6miu.com/read-58251.html

最新回复(0)