RAGHAVBDY - Editorial


Author: Pratik
Tester: Varun
Editorialist: Pratik




Math .


Raghav is a student of mathematics and computing . today is his birthday and you have to give him some special and unique gift. As he is a student of math he loves linear algebra . That’s why you decided to give him a special sequence of numbers A1,A2,A3,A4,A5.

The raghav will love sequence if and only if the sequence is in arithmetic progression. Sakshi is also a partner in your gift and she is going to help you in making the sequence… Sakshi told you the expected. Mean ( X ) , Common difference ( d ) and Sum of all elements of sequence ( S ) .


  • A1,A2,A3,A4,A5 are distinct
  • -100 ≤ A1,A2,A3,A4,A5 ≤ 100


So Create a sequence using information given by sakshi…


We have given value of Mean , common differance and sum of all terms , we have to just print five
consecitive terms i.e a-2d,a-d,a,a+d,a+2d .


Setter's Solution

using namespace std;

#define google(tc) cout<<“Case #”<<tc++<<": ";
#define FILE freopen(“input.txt”,“r”,stdin); freopen(“output.txt”,“w”, stdout);
#define GetSetBolt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define LD long double

#ifndef LOCAL
#pragma GCC optimize(“Ofast”)
#pragma GCC target(“avx,avx2,fma”)
#pragma GCC optimization(“unroll-loops”)
#pragma GCC optimize (“O3”)
#pragma GCC target (“sse4”)

#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define FF first
#define SS second
#define PB push_back
#define PF push_front
#define PPB pop_back
#define PPF pop_front
#define Endl endl

#define in(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define in2(arr,n,m) for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cin>>arr[i][j];}
#define dis(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" “; cout<<endl;
#define dis2(arr,n,m) for(int ii=0;ii<n;ii++){for(int j=0;j<m;j++)cout<<arr[ii][j]<<” ";cout<<endl;}
#define tc int t=0;cin>>t; while(t–)

#define For(n) for(ll i=0;i<n;i++)
#define For0(x,z) for(ll x=0;x<z;x++)
#define Forx(x,z) for(x;x<z;x++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

#define toLower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define toUpperr(s) transform(s.begin(),s.end(),s.begin(),::toupper)

#define sortAD(arr,n) sort(arr,arr+n, greater());
#define sortVD(v) sort(v.begin(), v.end(), greater());
#define sortA(arr) sort(arr,arr+n);
#define sortV(v) sort(v.begin(),v.end());

#define mem0(X) memset((X), 0, sizeof((X)))
#define memx(X,x) memset((X), x, sizeof((X)))
#define setbits(X) __builtin_popcountll(X)
#define precise(X) cout<<fixed << setprecision(X);
#define valid(x,y,row,col) (((x) >= 0 and (x) < row) and ((y) >= 0 and (y) < col))
#define debug(…) fprintf(stderr, VA_ARGS), fflush(stderr)
#define timer(d) for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); debug("%s:%.4fs",d,(double)(clock()-blockTime)/CLOCKS_PER_SEC))

// #ifndef ONLINE_JUDGE
// cerr<<"\ntime taken : “<<(float)clock()/CLOCKS_PER_SEC<<” secs"<<"\n";
// #endif
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<double,double> PDD;
typedef pair<string, string> PSS;
typedef pair<string, ll> PSL;
typedef long double lld;

typedef vector VI;
typedef vector VL;
typedef vector VD;
typedef vector VS;
typedef vector VVI;
typedef vector VVL;
typedef vector VVS;
typedef vector VPII;
typedef vector VPLL;
typedef vector VPSS;
typedef vector VPSL;

typedef map<int,int> MII;
typedef map<ll,ll> MLL;
typedef map<char,ll> MCL;
typedef map<char,int> MCI;
typedef map<char,ll> MCL;
typedef map<string,string> MSS;
typedef map<string,int> MSI;
typedef map<string,ll> MSL;

typedef unordered_map<int,int> UMII;
typedef unordered_map<ll,ll> UMLL;
typedef unordered_map<char,ll> UMCL;
typedef unordered_map<char,int> UMCI;
typedef unordered_map<char,ll> UMCL;
typedef unordered_map<string,string> UMSS;
typedef unordered_map<string,int> UMSI;
typedef unordered_map<string,ll> UMSL;
typedef unsigned long long ull;

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template void _print(vector v);
template void _print(set v);
template <class T, class V> void _print(map <T, V> v);
template void _print(multiset v);
template <class T, class V> void _print(pair <T, V> p) {cerr << “{”; _print(p.ff); cerr << “,”; _print(p.ss); cerr << “}”;}
template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << “]”;}
template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << “]”;}
template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << “]”;}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << “]”;}

ll lcm(ll a, ll b)
{ return (a * (b / __gcd(a, b))); }

string intToString(ll a)
char x[100];
sprintf(x, “%lld”, a);
string s = x;
return s;

ll stringToInt(string a)
char x[100];
ll res;
strcpy(x, a.c_str());
sscanf(x, “%lld”, &res);
return res;

bool isPrime(int n)
if (n <= 1)
return false;
for (int i = 2; i <= sqrt(n); i++)
if (n % i == 0)
return false;
return true;

string to_binary(ll n)
int bin[100];
int i = 0;
while (n > 0) {
bin[i] = n % 2;
n = n / 2;
string s="";
for(int j=i-1;j>=0;j–)
return s;

int main()

freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("errorf.txt" , "w" , stderr) ;

    // code here
    ll a,b,c;
    cin >> a >> b >> c;
    cout << (a-(2*b)) << " " << (a-b) << " " << a << " " << (a+b) << " " << (a+(2*b)) << "\n";

return 0;


Tester's Solution

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
import java.io.*;

class Main
public static void main (String[] args) throws java.lang.Exception
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();

	for(int i=0; i<test; i++){
	             int x = sc.nextInt();
	             int d = sc.nextInt();
	             int s = sc.nextInt();
	             int a1,a2,a3,a4,a5 = 0;
	             a3 = x;
	             a2 = a3-d;
	             a1 = a3-2*d;
	             a4 = a3+d;
	             a5 = a3+2*d;
	            System.out.println(a1 + " " + a2 + " " + a3 + " " + a4 + " " +  a5);