福建师范大学1908(小丁的试验)

福建师范大学1908(小丁的试验)
http://acm.fjnu.edu.cn/show?problem_id=1908
亮着的个数是其完全平方的个数
import  java.util. * ;
import  java.io. * ;

public   class  ACM_1908 {
    
    
public static int count(int n){
        
int i,count = 0;
        
for(i=1;i<=n;i++){
            
long tmp = i*i;
            
if(tmp<=n)
                count
++;
            
else
                
break;
        }

        
return count;
    }


    
public static void main(String rgs[]) throws Exception
    
{
        BufferedReader stdin 
= new BufferedReader(new InputStreamReader(System.in));
        String line 
= stdin.readLine();
        StringTokenizer st 
= new StringTokenizer(line);
        
int i,T = Integer.parseInt(st.nextToken());
        
for(i=0;i<T;i++){
            line 
= stdin.readLine();
            st 
= new StringTokenizer(line);
            
int n = Integer.parseInt(st.nextToken());
            
int t = Integer.parseInt(st.nextToken());
            
int x = count(n);
            
if(n-x==t) 
                System.out.println(
"YES");
            
else
                System.out.println(
"NO");
        }
   
    }

}

你可能感兴趣的:(福建师范大学1908(小丁的试验))