-
Notifications
You must be signed in to change notification settings - Fork 8
/
Manasa&Stones.cpp
57 lines (50 loc) · 958 Bytes
/
Manasa&Stones.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>
using namespace std;
/*int* duprem(int ch[],int len,int cnew[],int i,int k)
{
if(i==len)
{
//cnew[k]='\0';
return(cnew);
}
if(ch[i]!=ch[i+1])
cnew[k++]=ch[i];
duprem(ch,len,cnew,i+1,k);
}
*/
bool notpresent(vector<int>v,int se)
{
int p;
int n1 = v.size();
for(p=0;p<n1;p++)
{
if(v[p]==se)
return false;
}
return true;
}
int main()
{
int q,n,a,b,x,i;
cin>>q;
vector<int>v;
while(q--)
{
cin>>n>>a>>b;
for(i=0;i<n;i++)
{
x = (n-i-1)*a + (i)*b;
if(notpresent(v,x))
v.push_back(x);
}
sort(v.begin(),v.end());
//int valnew[1000];
//duprem(val,j,valnew,0,0);
//int s = sizeof(valnew)/sizeof(int);
for(i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
while(!v.empty())
v.pop_back();
}
}