-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcf.java
More file actions
79 lines (75 loc) · 1.77 KB
/
cf.java
File metadata and controls
79 lines (75 loc) · 1.77 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.util.*;
public class cf
{
public static void main(String[] args)
{
Scanner ob=new Scanner(System.in);
int n=ob.nextInt();
int k=ob.nextInt();
String s1="",s2="";int i,j,c=0,ind=0;
int a[]=new int[n];int t,temp,l=0;
int b[]=new int[n];
for(i=0;i<n;i++)
{
a[i]=ob.nextInt();
}
for(i=0;i<n;i++)
{
t=a[i];
for(j=0;j<n;j++)
{
if(i==j)
{
continue;
}
else
{
s1=t+""+a[j];
s2=a[j]+""+t;
if(Integer.parseInt(s1)%k==0)
//||Integer.parseInt(s2)%k==0)//&&(Integer.parseInt(s1)!=Integer.parseInt(s2)))
{
b[ind]=Integer.parseInt(s1);
ind++;
}
else if(Integer.parseInt(s2)%k==0)
{
b[ind]=Integer.parseInt(s2);
ind++;
}
else
{
ind++;
}
}
// c++;
//System.out.println(s1+" "+s2);
}
s1="";s2="";
}
for(i=0;i<ind;i++)
{
for(j=0;j<(ind-1-i);j++)
{
if(b[j]>b[j+1])
{
temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
for(i=0;i<ind;i+=c)
{
l++;;
for(j=0;j<ind;j++)
{
if(b[i]==b[j])
{
c++;
}
}
}
System.out.println(l);
}
}