-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.java
More file actions
42 lines (36 loc) · 730 Bytes
/
Copy pathB.java
File metadata and controls
42 lines (36 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
import java.io.*;
public class cf{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int sum=0;
int i=1;
int count=0;
while(sum<n){
sum+=i;
i++;
count++;
}
// int b[]=new int[count];
// int s=2;
// for(int j=0;j<count;j++){
// b[j]=s;
// s++;
// }
int a=sum-n;
if(a==0){
System.out.println(count);
}
else if(a==1)
{
System.out.println(count+1);
}
else{
System.out.println(count);
}
}
}
}