Skip to content

Commit

Permalink
Uploaded AtCoder Contest accepted submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
SambhavJain74 authored Sep 24, 2023
1 parent 26c6588 commit 987515c
Show file tree
Hide file tree
Showing 33 changed files with 1,452 additions and 0 deletions.
15 changes: 15 additions & 0 deletions AtCoder/abc292/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<iostream>
using namespace std;

int main()
{
char s[100];
cin>>s;
int i=0;
while(s[i]!='\0')
{
cout<<(char)(int(s[i]-32));
i++;
}
return 0;
}
34 changes: 34 additions & 0 deletions AtCoder/abc292/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<iostream>
using namespace std;

int main()
{
int n,q;
cin>>n>>q;
int arr[n][2]={0,0}; // yellow, red, index=number-1
int temp1,x;
for(int i=0;i<q;i++)
{
cin>>temp1>>x;
if(temp1==1)
{
arr[x-1][0]++;
}
else if(temp1==2)
{
arr[x-1][1]++;
}
else
{
if(arr[x-1][0]>=2||arr[x-1][1]>=1)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
}
return 0;
}
34 changes: 34 additions & 0 deletions AtCoder/abc292/c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<iostream>
#include<cmath>
using namespace std;

int cntdiv(int n)
{
int cnt = 0;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i)
cnt++;

else // Otherwise count both
cnt = cnt + 2;
}
}
return cnt;
}

int main()
{
int n;
cin>>n;
long long answer=0;
for(int i=1,j=n-1;i<j;i++,j--)
{
answer+=cntdiv(i)*cntdiv(j)*2;
}
if(n%2==0)
{
answer+=pow(cntdiv(n/2),2);
}
cout<<answer;
}
15 changes: 15 additions & 0 deletions AtCoder/abc292/f.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include<iostream>
#include<cmath>
using namespace std;
int main(){
long double a,b;
cin>>a>>b;
cout.precision(15);
if(sqrt(3)*max(a,b)<=2*min(a,b)){
cout<<2*sqrt(a*a+b*b-a*b*sqrt(3));
}
else{
cout<<2*min(a,b)/sqrt(3);
}
return 0;
}
36 changes: 36 additions & 0 deletions AtCoder/abc296/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include<iostream>
using namespace std;

int main()
{
int n;
bool done=false;
char temp1,temp2;
cin>>n;
cin>>temp1;
int i=2;
for(;i<=n;i++)
{
cin>>temp2;
if(temp1==temp2)
{
done=true;
break;
}
temp1=temp2;
}
i++;
for(;i<=n;i++)
{
cin>>temp2;
}
if(done)
{
cout<<"No"<<endl;
}
else
{
cout<<"Yes"<<endl;
}

}
46 changes: 46 additions & 0 deletions AtCoder/abc299/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include<iostream>
#include<bits/stdc++.h>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;

int main()
{
int n,temp,first,second,third;
cin>>n;
string s;
cin>>s;
for(int i=0;i<n;i++)
{
if(s[i]=='|')
{
first=i;
break;
}
}
for(int i=0;i<n;i++)
{
if(s[i]=='*')
{
second=i;
break;
}
}
for(int i=n-1;i>=0;i--)
{
if(s[i]=='|')
{
third=i;
break;
}
}
if(first<second&&second<third)
{
cout<<"in"<<endl;
}
else
{
cout<<"out"<<endl;
}
return 0;
}
27 changes: 27 additions & 0 deletions AtCoder/abc303/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<bits/stdc++.h>
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define endl "\n"
#define int long long
using ll=long long;
using namespace std;

int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
bool answer=true;
string s,t;
cin>>n>>s>>t;
for(int i=0;i<n;i++)
{
if(!(s[i]==t[i]||s[i]=='1'&&t[i]=='l'||s[i]=='l'&&t[i]=='1'||s[i]=='o'&&t[i]=='0'||s[i]=='0'&&t[i]=='o'))
{
answer=false;
break;
}
}
(answer)?yes:no;
return 0;
}
46 changes: 46 additions & 0 deletions AtCoder/abc303/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include<bits/stdc++.h>
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define endl "\n"
#define int long long
using ll=long long;
using namespace std;

int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n,m,a,b,count=0;
cin>>n>>m;
int arr[n][n]={0};
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
arr[i][j]=0;
}
}
for(int i=1;i<=m;i++)
{
cin>>a;
for(int j=2;j<=n;j++)
{
cin>>b;
arr[a-1][b-1]=1;
arr[b-1][a-1]=1;
a=b;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(arr[i][j]==0)
{
count++;
}
}
}
cout<<(count-n)/2<<endl;
return 0;
}
28 changes: 28 additions & 0 deletions AtCoder/abc305/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<bits/stdc++.h>
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define endl "\n"
#define int long long
using ll=long long;
using namespace std;

int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
if(n>=100)
{
cout<<100<<endl;
}
else if(n%5>=3)
{
cout<<5*(n/5)+5<<endl;
}
else
{
cout<<5*(n/5)<<endl;
}
return 0;
}
74 changes: 74 additions & 0 deletions AtCoder/abc305/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include<bits/stdc++.h>
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define endl "\n"
#define int long long
using ll=long long;
using namespace std;

int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
char p,q;
int a,b;
cin>>p>>q;
if(p=='A')
{
a=0;
}
else if(p=='B')
{
a=3;
}
else if(p=='C')
{
a=4;
}
else if(p=='D')
{
a=8;
}
else if(p=='E')
{
a=9;
}
else if(p=='F')
{
a=14;
}
else
{
a=23;
}
if(q=='A')
{
b=0;
}
else if(q=='B')
{
b=3;
}
else if(q=='C')
{
b=4;
}
else if(q=='D')
{
b=8;
}
else if(q=='E')
{
b=9;
}
else if(q=='F')
{
b=14;
}
else
{
b=23;
}
cout<<abs(a-b)<<endl;
return 0;
}
Loading

0 comments on commit 987515c

Please sign in to comment.