-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha005.cpp
More file actions
36 lines (31 loc) · 750 Bytes
/
a005.cpp
File metadata and controls
36 lines (31 loc) · 750 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
/*
Date: 09/27/2020
Author: ELV
Question: https://zerojudge.tw/ShowProblem?problemid=a005
Finish the arithmetic sequence or geometric sequence.
*/
#include <iostream>
using namespace std;
int main()
{
short ques, ans;
cin >> ques;
for(short n=1; n<ques+1; n++)
{
short a, b, c, d;
cin >> a >> b >> c >> d;
// 等差數列
if( (c-b) == (b-a) )
{
ans = d+(b-a);
cout << a << " " << b << " " << c << " " << d << " " << ans << endl;
}
// 等比數列
else if( (c/b) == (b/a) )
{
ans = d*(b/a);
cout << a << " " << b << " " << c << " " << d << " " << ans << endl;
}
}
return 0;
}