ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1209. 1, 10, 100, 1000...

plz tell me why my answer is wrong
Posted by MichealChen 29 Jun 2016 13:36
//i try to run the code passed, i seems it make the same answer as me
//i don't know what's wrong accur,plz help me.Does there is any wrong in way i solve this problem?
import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner cin = new Scanner ( System.in );
        int a,temp;//count store time of test
        //find 1,1 is easy to find
        //1 is at (n+1)n/2 +1
        int count=cin.nextInt();
        for (int j=1; j<=count; j++) {
            a=cin.nextInt();
            temp=(int) Math.floor(Math.sqrt(2*(j-1)));
            if((temp*(temp+1)/2+1)==j){
                System.out.print("1 ");
            }else {
                System.out.print("0 ");
            }
        }
    }
}