Skip to content

Commit 5bf45c1

Browse files
committed
20-04-2021
1 parent 93487fe commit 5bf45c1

40 files changed

+1230
-136
lines changed

codeforces/CF1512A.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include<iostream>
2+
using namespace std;
3+
int solve(){
4+
int n ;
5+
cin>>n;
6+
int *br = new int[101];
7+
int *ar = new int[101];
8+
for(int i=0;i<101;i++){
9+
br[i]=0;
10+
}
11+
int a;
12+
for(int i =0;i<n;i++){
13+
cin>>a;
14+
ar[i]=a;
15+
br[a]++;
16+
}
17+
int el ;
18+
for(int i =0;i<101;i++){
19+
if(br[i]!=0 && br[i]==1){
20+
el = i;
21+
}
22+
}
23+
for(int i =0;i<n;i++){
24+
if(el==ar[i]){
25+
return i+1;
26+
}
27+
}
28+
return 0;
29+
}
30+
31+
int main(){
32+
int t;
33+
cin>>t;
34+
while(t--){
35+
cout<<solve()<<endl;
36+
}
37+
return 0;
38+
}

codeforces/CF1512B.cpp

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#include<iostream>
2+
using namespace std;
3+
int up(char **ar ,int n,int i , int j){
4+
if(j>=0){
5+
return 0;
6+
}
7+
if(ar[i][j]=='*'){
8+
return 1;
9+
}
10+
return up(ar,n,i,j-1);
11+
}
12+
13+
int down(char **ar ,int n,int i , int j){
14+
if(j<n){
15+
return 0;
16+
}
17+
if(ar[i][j]=='*'){
18+
return 1;
19+
}
20+
return down(ar,n,i,j+1);
21+
}
22+
int left(char **ar ,int n,int i , int j){
23+
if(j>=0){
24+
return 0;
25+
}
26+
if(ar[i][j]=='*'){
27+
return 1;
28+
}
29+
return left(ar,n,i-1,j);
30+
}
31+
32+
int right(char **ar ,int n,int i , int j){
33+
if(i<n){
34+
return 0;
35+
}
36+
if(ar[i][j]=='*'){
37+
return 1;
38+
}
39+
return right(ar,n,i+1,j);
40+
}
41+
42+
43+
44+
void solve(){
45+
int n ;
46+
cin>>n;
47+
char **ar = new char*[n];
48+
for(int i =0;i<n;i++){
49+
ar[i]= new char[n];
50+
}
51+
for(int i =0;i<n;i++){
52+
for(int j =0;j<n;j++){
53+
cin>>ar[i][j];
54+
}
55+
}
56+
for(int i =0;i<n;i++){
57+
for(int j =0;j<n;j++){
58+
if((up(ar,n,i,j)+down(ar,n,i,j)+left(ar,n,i,j)+right(ar,n,i,j))>0){
59+
ar[i][j]='*';
60+
}
61+
}
62+
}
63+
64+
for(int i =0;i<n;i++){
65+
for(int j =0;j<n;j++){
66+
cout<<ar[i][j]<<" ";
67+
}
68+
cout<<endl;
69+
}
70+
cout<<endl;
71+
}
72+
73+
int main(){
74+
int t;
75+
cin>>t;
76+
while(t--){
77+
solve();
78+
}
79+
return 0;
80+
}

codeforces/CF1514A.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
typedef long long int ll;
4+
5+
bool isperfectSquare(ll n){
6+
ll x = sqrt(n);
7+
return n==x*x;
8+
}
9+
10+
void solve(){
11+
ll n ;
12+
cin>>n;
13+
ll *ar = new ll[n];
14+
bool flag = true;
15+
for(int i =0;i<n;i++){
16+
cin>>ar[i];
17+
}
18+
for(int i =0;i<n;i++){
19+
if(!isperfectSquare(ar[i])){
20+
flag = false; break;
21+
}
22+
}
23+
if(!flag){
24+
cout<<"Yes\n";
25+
}else{
26+
cout<<"No\n";
27+
}
28+
}
29+
int main(){
30+
int t;
31+
cin>>t;
32+
while(t--){
33+
solve();
34+
}
35+
return 0;
36+
}

codeforces/CF1514B.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
typedef long long int ll;
4+
ll _max = LLONG_MIN;
5+
ll _k;
6+
7+
void subset(vector<ll>ar, int i ,int n , vector<ll>pr){
8+
if(i==n-1){
9+
cout<<i<<" "<<n-1<<endl;
10+
}else{
11+
pr.push_back(ar[i]);
12+
subset(ar,i+1,n,pr);
13+
pr.pop_back();
14+
subset(ar,i+1,n,pr);
15+
cout<<_max<<endl;
16+
}
17+
}
18+
19+
void solve(){
20+
ll n,k;
21+
cin>>n>>k;
22+
_k=k;
23+
ll l = pow(2,k);
24+
cout<<l<<endl;
25+
vector<ll> ar,pr;
26+
for(int i =0;i<=l;i++){
27+
ar.push_back(i);
28+
}
29+
subset(ar,0,ar.size(),pr);
30+
}
31+
32+
int main(){
33+
ios::sync_with_stdio(0);
34+
cin.tie(0);
35+
int t;
36+
cin>>t;
37+
while(t--){
38+
solve();
39+
}
40+
return 0;
41+
}

codeshef/ADADISH.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
typedef long long int ll;
4+
5+
bool f(int a,int b){
6+
return a-b;
7+
}
8+
9+
void solve(){
10+
ll n;
11+
cin>>n;
12+
int *ar = new int[n];
13+
int sum =0;
14+
for(int i =0;i<n;i++){
15+
cin>>ar[i];
16+
sum+=ar[i];
17+
}
18+
int ans = sum;
19+
for(int i =0;i<n;i++){
20+
int k = max(ar[i],sum-ar[i]);
21+
ans = min (ans,k);
22+
}
23+
24+
for(int i =0;i<n;i++){
25+
for(int j =i+1;j<n;j++){
26+
int t = ar[i]+ar[j];
27+
int k = max(t,sum-t);
28+
ans = min(ans,k);
29+
}
30+
}
31+
32+
}
33+
int main(){
34+
int t;
35+
cin>>t;
36+
while(t--){
37+
solve();
38+
}
39+
return 0;
40+
}

codeshef/BOLT.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include<iostream>
2+
#include <cmath>
3+
using namespace std;
4+
void solve(){
5+
float k1,k2,k3,v;
6+
cin>>k1>>k2>>k3>>v;
7+
float finalSpeed = k1*k2*k3*v;
8+
float time = 100/finalSpeed;
9+
float precise_speed =round(time*100.0)/100.0;
10+
11+
if(precise_speed < (float)9.58){
12+
cout<<"YES\n";
13+
}else{
14+
cout<<"NO\n";
15+
}
16+
}
17+
int main(){
18+
int t;
19+
cin>>t;
20+
while(t--){
21+
solve();
22+
}
23+
return 0;
24+
}

codeshef/BRKBKS.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
void solve(){
4+
int st;
5+
int *ar = new int[3];
6+
cin>>st;
7+
int a;
8+
for(int i =0;i<3;i++){
9+
cin>>ar[i];
10+
}
11+
int s1 = ar[0]+ar[1]+ar[2];
12+
int s2 = ar[0]+ar[1];
13+
int s3 = ar[0]+ar[2];
14+
if(st>=s1){
15+
cout<<"1\n";
16+
}
17+
else if (st>=s2 || st>=s3){
18+
cout<<"2\n";
19+
}
20+
else {
21+
cout<<"3\n";
22+
}
23+
}
24+
int main(){
25+
int t;
26+
cin>>t;
27+
while(t--){
28+
solve();
29+
}
30+
return 0;
31+
}

codeshef/CANDY123.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
typedef long long int ll;
4+
5+
void solve(){
6+
int a,b;
7+
cin>>a>>b;
8+
int candies = 1;
9+
int player = 1;
10+
while(true){
11+
if(player==1){
12+
a-=candies;
13+
player=2;
14+
}else{
15+
b-=candies;
16+
player=1;
17+
}
18+
candies++;
19+
if(a<0 || b<0){
20+
break;
21+
}
22+
}
23+
if(player==1){
24+
cout<<"Limak\n";
25+
}else{
26+
cout<<"Bob\n";
27+
}
28+
}
29+
int main(){
30+
int t;
31+
cin>>t;
32+
while(t--){
33+
solve();
34+
}
35+
return 0;
36+
}

codeshef/CASH.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
typedef long long int ll;
4+
void solve(){
5+
ll n,k;
6+
cin>>n>>k;
7+
ll sum = 0;
8+
ll a;
9+
for(int i =0;i<n;i++){
10+
cin>>a;
11+
sum+=a;
12+
}
13+
cout<<sum%k<<endl;
14+
}
15+
int main(){
16+
int t;
17+
cin>>t;
18+
while(t--){
19+
solve();
20+
}
21+
return 0;
22+
}

0 commit comments

Comments
 (0)