[NYOJ] [1769] Showdown

Problem Description

Loading...

Problem Analysis

Note that the question asks whether such a pair exists
not whether it can be done within k rounds

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include<stdio.h>
int n,k;
bool judge() {
    for(int i=1; i<=n/2; i++) {
        if(i*(n-i)==k)
            return true;
    }
    return false;
}
int main() {
    while(scanf("%d %d",&n,&k),n||k)
        printf("%s\n",judge()?"YES":"NO");
    return 0;
}
This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...