-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathModEquality.java
More file actions
39 lines (32 loc) · 1.18 KB
/
ModEquality.java
File metadata and controls
39 lines (32 loc) · 1.18 KB
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
package codechef.JuluCockoff;
import java.util.Scanner;
public class ModEquality {
public static void main(String[] arr){
Scanner sc = new Scanner(System.in);
int testCase=sc.nextInt();
while(testCase-->0){
int totalElementCount= sc.nextInt();
long minElement=Long.MAX_VALUE;
long[] elementArray=new long[totalElementCount];
for(int i=0;i<totalElementCount;i++){
long input=sc.nextLong();
minElement = Math.min(input,minElement);
elementArray[i]=input;
}
long totalStep=0;
boolean flag=false;
for(int i=0;i<totalElementCount;i++){
if(elementArray[i]==minElement) continue;
long processElement=(elementArray[i])%(elementArray[i]-minElement);
if(processElement==minElement){
totalStep++;
}else {
flag=true;
break;
}
}
if(flag) System.out.println(totalElementCount);
else System.out.println(totalStep);
}
}
}