forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKilljoy.cpp
57 lines (51 loc) · 956 Bytes
/
Killjoy.cpp
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
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll t;
cin >> t;
while (t--)
{
ll n, x;
cin >> n >> x;
ll arr[n];
ll flag = 0;
ll cnt = 0;
for (ll i = 0; i < n; i++)
{
cin >>arr[i];
if (arr[i] == x)
{
flag = 1;
cnt++;
}
}
if (cnt == n)
{
cout << 0 << "\n";
continue;
}
if (flag == 1)
{
cout << 1 << "\n";
continue;
}
ll sum = 0;
for (ll i = 0; i < n; i++)
{
sum += (arr[i] - x);
}
if (sum == 0)
{
cout << 1 << '\n';
}
else
{
cout << 2 << '\n';
}
}
return 0;
}