Fork me on GitHub

NYOJ题目813对决

---------------------------------

水题也有坑...注意是k场而不是k场内。

 

AC代码:

 1 import java.util.Scanner;
 2 
 3 public class Main {
 4 
 5     public static void main(String[] args) {
 6         
 7         Scanner sc=new Scanner(System.in);
 8         
 9         while(true){
10             
11             int n=sc.nextInt();
12             int k=sc.nextInt();
13             
14             if(n==0 && k==0) break ;
15             
16 //            System.out.println(k>=n-1?"Yes":"No");
17             
18             boolean ok=false;
19             for(int i=1;i<=n/2;i++){
20                 if(i*(n-i)==k){
21                     ok=true;
22                     System.out.println("YES");
23                     break;
24                 }
25             }
26             if(!ok) System.out.println("NO");
27             
28         }
29         
30     }
31     
32 }

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=813

posted @ 2016-08-31 09:26  CC11001100  阅读(174)  评论(0编辑  收藏  举报