Skip to content

Commit 6fe210f

Browse files
authored
Merge pull request #239 from sanchitgupta456/master
Added Codeforces Round 638 Problem A & Problem B
2 parents 07e254f + fd1e1d9 commit 6fe210f

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**************************************************************************
2+
* $Id$
3+
* File:
4+
*
5+
* Purpose:
6+
*
7+
* Author: Sanchit Gupta (CS19B071)
8+
*
9+
* Created:
10+
*
11+
* Last modified:
12+
*
13+
* Bugs:
14+
*
15+
* Change Log:
16+
*
17+
* While(!(succeed==try());
18+
**************************************************************************/
19+
#include<iostream>
20+
#include<bits/stdc++.h>
21+
22+
using namespace std;
23+
24+
int main()
25+
{
26+
int t;
27+
cin>>t;
28+
while(t--)
29+
{
30+
long long int n;
31+
cin>>n;
32+
long long int sum1=0,sum2=0;
33+
long long int current=2,i=1;
34+
while(i<(n/2))
35+
{
36+
sum1=sum1+current;
37+
current=current*2;
38+
i++;
39+
}
40+
while(i<n)
41+
{
42+
sum2=sum2+current;
43+
current=current*2;
44+
i++;
45+
}
46+
sum1=sum1+current;
47+
cout<<abs(sum1-sum2)<<endl;
48+
}
49+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**************************************************************************
2+
* $Id$
3+
* File:
4+
*
5+
* Purpose:
6+
*
7+
* Author: Sanchit Gupta (CS19B071)
8+
*
9+
* Created:
10+
*
11+
* Last modified:
12+
*
13+
* Bugs:
14+
*
15+
* Change Log:
16+
*
17+
* While(!(succeed==try());
18+
**************************************************************************/
19+
#include <bits/stdc++.h>
20+
using namespace std;
21+
22+
int main(){
23+
int t; cin>>t;
24+
while (t--)
25+
{
26+
int n,k;
27+
cin>>n,k;
28+
set<int>s;
29+
for (int i=0;i<n;i++){
30+
int a;
31+
cin>>a;
32+
s.insert(a);
33+
}
34+
if (s.size()>k){
35+
cout<<-1<<endl;
36+
return;
37+
}
38+
cout<<n*k<<endl;
39+
for (int i=0;i<N;i++){
40+
for (int b:s)
41+
cout<<b<<' ';
42+
for (int j=0;j<k-(int)s.size();j++)
43+
cout<<1<<' ';
44+
}
45+
cout<<endl;
46+
}
47+
}

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ Problem Statement | Solution
8484
[B](https://codeforces.com/contest/1341/problem/B) | [Solution](https://github.com/larissalages/code_problems/blob/master/Codeforces_Contests/6_Round_637_Div_2/B.cpp)
8585
[C](https://codeforces.com/contest/1341/problem/C) | [Solution](https://github.com/larissalages/code_problems/blob/master/Codeforces_Contests/6_Round_637_Div_2/C.cpp)
8686

87+
### Round 638
88+
Problem Statement | Solution
89+
------------ | -------------
90+
[A](https://codeforces.com/contest/1348/problem/A) | [Solution](https://github.com/sanchitgupta456/code_problems/blob/master/Codeforces_Contests/Round_638_Div_2/A.cpp)
91+
8792
# LeetCode
8893
## Binary Search Trees
8994
Challenge | Solution

0 commit comments

Comments
 (0)