zoukankan      html  css  js  c++  java
  • nyoj 813-对决 (i*j == k)

    813-对决


    内存限制:64MB 时间限制:1000ms 特判: No
    通过数:11 提交数:23 难度: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

    C/C++ :

    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <cmath>
    #include <stack>
    #include <set>
    #include <map>
    #include <queue>
    #include <climits>
    #include <bitset>
    #define PI 3.1415926
    
    using namespace std;
    
    bool judge(int n, int k)
    {
        int nn = n / 2;
        for (int i = 1; i <= nn; ++ i)
        {
            if (i * (n - i) == k)
                return true;
        }
        return false;
    }
    
    int main()
    {
        int n, k;
        while (cin >>n >>k, n || k)
        {
            if (judge(n, k))
                printf("YES
    ");
            else
                printf("NO
    ");
        }
    
        return 0;
    }
  • 相关阅读:
    2019省赛训练组队赛4.9周二 2017浙江省赛
    #Leetcode# 49. Group Anagrams
    #Leetcode# 57. Insert Interval
    POJ 2195 Going Home
    HDU 2255 奔小康赚大钱
    HDU 1083 Courses
    HDU 2063 过山车
    POJ 3041 Asteroids
    指针的妙处
    jzoj 6273. 2019.8.4【NOIP提高组A】欠钱 (money)
  • 原文地址:https://www.cnblogs.com/GetcharZp/p/9354151.html
Copyright © 2011-2022 走看看