-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinc_k.cpp
More file actions
72 lines (64 loc) · 896 Bytes
/
inc_k.cpp
File metadata and controls
72 lines (64 loc) · 896 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
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
#include <stdio.h>
int max (int a,int b)
{
return (a > b) ? b : a;
}
int GCD (int arr[],int n)
{
int high = 0;
for (int i=0;i<n;i++)
{
high = max (high,arr[i]);
}
int div[high+1];
for (int i=0;i<n;i++)
{
for (int j=1;j<=sqrt(arr[i]);j++)
{
if (arr[i] % j == 0)
{
div[j]++;
if (j != arr[i]/j)
{
div [arr[i]/j]++;
}
}
}
}
for (int i=high ;j >=1;i--)
{
if (div[i]>1)
{
return i;
}
}
}
int main ()
{
int N;
int x;
int count =0 ;
scanf ("%d",&N);
int arr[N];
for (int i=0;i<N;i++)
{
scanf ("%d",&arr[i]);
}
// for (int i=0;i<N-1;i++)
// {
// for (int j=0;j<N-i-1;j++)
// {
//
// if( (GCD(arr[j],arr[j+1]))% 2 != 0)
// {
// count++;
// }
// else
// continue;
//
// }
// }
GCD (arr[],n);
printf ("%d",count);
return 0;
}