对决
Time Limit:1000MS Memory Limit:65536K
Total Submit:19 Accepted:15
Description
Topcoder 招进来了 n 个新同学,Yougth计划把这个n个同学分成两组,要求每组中每个人必须跟另一组中每个同学进行一次算法对决,问存不存在一种分组方式在k场完成对决。(两组中每一组中人数都要大于0)
Input
有多组测试数据,每组测试数据两个数 n 和 k ,n和k都为0时表示输入结束。(0 < n < 10000,0 < k < 1000000)
Output
输出一行,如果可以,输出YES,不行的话输出NO。
Sample Input
4 1
4 3
4 4
2 1
3 3
0 0
Sample Output
NO
YES
YES
YES
NO
Source
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AK1182 {
class Program {
static void solve(int a, int b) {
int[] s = new int[1001];
bool flag = false;
for (int i = 1; i <= a / 2; i++) {
s[i] = i * (a - i);
if (s[i] == b) {
Console.WriteLine("YES");
flag = true;
break;
}
}
if (!flag)
Console.WriteLine("NO");
}
static void Main(string[] args) {
string sb;
while ((sb = Console.ReadLine()) != null) {
string[] s = sb.Split();
int a = int.Parse(s[0]), b = int.Parse(s[1]);
if (a + b == 0) break;
solve(a, b);
}
}
}
}