-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapcompletion.cpp
More file actions
43 lines (37 loc) · 790 Bytes
/
apcompletion.cpp
File metadata and controls
43 lines (37 loc) · 790 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
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define MOD 1000000007
void CowboyBebop(){
int n ;
cin >> n ;
int arr[n];
for(int i = 0 ; i < n ; i++){
cin >> arr[i];
}
int d = floor((arr[0] + arr[n-1])/n);
int k ;
for (int i = 0,k = 0 ; i < n; i++,k++)
{
if(arr[i] == (arr[0] + k*d)){
continue;
}
else{
cout << arr[0] + k*d << " is missing from the AP" << endl ;
k++;
}
}
}
using namespace std;
int main(void){
std::ios_base::sync_with_stdio(false);
// #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int t ;
cin >> t;
while(t--){
CowboyBebop();
}
return 0;
}