-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path11066_AP3.cpp
50 lines (47 loc) · 1.03 KB
/
11066_AP3.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
/*
TASK: AP - Complete The Series (Easy)
Input:
1
3 8 55
Output:
10
1 2 3 4 5 6 7 8 9 10
*/
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int i, j, tN;
long long int tm, ltm, sum, num, d, a, b, c;
cin>>tN;
vector<long long int> input;
for(i=0;i<tN;i++)
{
cin>>tm;
cin>>ltm;
cin>>sum;
input.push_back(tm);
input.push_back(ltm);
input.push_back(sum);
}
for(i=0;i<tN;i++)
{
a=input[3*i+1]+input[3*i];
b=input[3*i]*7+input[3*i+1]*5+input[3*i+2]*2;
c=12*input[3*i+2];
/*cout<<"a = "<<a<<", b = "<<b<<", c = "<<c<<endl;
cout<<b*b-4*a*c<<endl;
num1 = (b-sqrt(float(b*b-4*a*c)))/a/2;*/
num = (b+sqrt(float(b*b-4*a*c)))/a/2;
/*cout<<num1<<", "<<num2<<endl;*/
cout<<num<<endl;
d=(input[3*i+1]-input[3*i])/(num-6);
for(j=0;j<num-1;j++)
{
cout<<input[3*i]+(j-2)*d<<" ";
}
cout<<input[3*i+1]+3*d<<endl;
}
return 0;
}