Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions solutions/110A_Nearly_Lucky_Number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
long long n;
cin>>n;
long long count=0;
while(n!=0){
int x=n%10;
n/=10;
if(x==4 || x==7){
count++;
}
}
if(count==0) {
cout<<"NO"<<endl;
return 0;
}
bool flag=true;
while(count!=0){
int x=count%10;
count/=10;
if(x!=4 && x!=7){
flag=false;
cout<<"NO"<<endl;
break;
}
}
if(flag) cout<<"YES"<<endl;
return 0;
}
13 changes: 13 additions & 0 deletions solutions/112A_Petya_and_Strings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
string a,b;
cin>>a>>b;
for(auto &c: a) c=tolower(c);
transform(b.begin(),b.end(),b.begin(),::tolower);
cout<<a.compare(b)<<endl;
return 0;
}
22 changes: 22 additions & 0 deletions solutions/116A_Tram.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int n;
cin>>n;
int total=0;
int min=0;
while(n--){
int x;
cin>>x;
total-=x;
cin>>x;
total+=x;
if(total>min)
min=total;
}
cout<<min<<endl;
return 0;
}
24 changes: 24 additions & 0 deletions solutions/136A_Presents.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int n;
cin>>n;
vector<int> v;
for(int i=0;i<n;i++){
int temp;
cin>>temp;
v.push_back(temp);
}
int a[n];
int num=1;
for(int x:v){
a[x-1]=num;
num++;
}
for(int x:a)
cout<<x<<" ";
return 0;
}
15 changes: 15 additions & 0 deletions solutions/141A_Amusing_Joke.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
string a,b,c,s;
cin>>a>>b>>c;
s=a+b;
sort(s.begin(),s.end());
sort(c.begin(),c.end());
if(s==c) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
36 changes: 36 additions & 0 deletions solutions/144A_Arrival_of_the_General.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include <bits/stdc++.h>
using namespace std;

int main()
{
int n;
cin >> n;
int maxindex=0;
int minindex=0;
int maxvalue=INT_MIN;
int minvalue=INT_MAX;
for (int i = 0; i < n; i++)
{
int temp;
cin >> temp;
if(temp>maxvalue){
maxindex=i;
maxvalue=temp;
}
if(temp<=minvalue){
minindex=i;
minvalue=temp;
}
}

int ans=(maxindex)+(n-minindex-1);
if(minindex<maxindex){
cout<<ans-1<<endl;;
}else{
cout<<ans<<endl;
}

return 0;
}
20 changes: 20 additions & 0 deletions solutions/148A_Insomnia_Cure.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int a[4],d;
cin>>a[0]>>a[1]>>a[2]>>a[3]>>d;
int j;
set<int> s;
for(int i=0;i<4;i++){
j=1;
while(a[i]*j<=d){
if(a[i]*j<=d) s.insert(a[i]*j);
j++;
}
}
cout<<s.size()<<endl;
return 0;
}
29 changes: 29 additions & 0 deletions solutions/155A_I_love_%username.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int n;
cin>>n;
vector<int> v;
for(int i=0;i<n;i++)
{
int temp;
cin>>temp;
v.push_back(temp);
}
int min=v[0],max=v[0],ans=0;
for(auto x:v){
if(x>max){
max=x;
ans++;
}
if(x<min){
min=x;
ans++;
}
}
cout<<ans<<endl;
return 0;
}
22 changes: 22 additions & 0 deletions solutions/158A_Next_Round.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int n,k;
cin>>n>>k;
vector<int> a;
for(int i=0;i<n;i++){
int temp;
cin>>temp;
a.push_back(temp);
}
int c=a[k-1];
int count=0;
for(int x:a){
if(x>=c && x>0) count++;
}
cout<<count<<endl;
return 0;
}
15 changes: 15 additions & 0 deletions solutions/41A_Translation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
string a,b;
cin>>a>>b;
for(int i=0;i<a.length()/2;i++){
swap(a[i],a[a.length()-1-i]);
}
if(a==b) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
12 changes: 12 additions & 0 deletions solutions/4A_Watermelon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int w;
cin>>w;
if(w%2==0 && w>2) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
11 changes: 11 additions & 0 deletions solutions/50A_Domino_Piling.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int m,n;
cin>>m>>n;
cout<<(n*m)/2<<endl;
return 0;
}
19 changes: 19 additions & 0 deletions solutions/59A_Word.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
string s;
cin>>s;
int u=0,l=0;
for(auto x:s){
if(isupper(x)) u++;
else l++;
}
if(u>l){
transform(s.begin(),s.end(),s.begin(),::toupper);
}else transform(s.begin(),s.end(),s.begin(),::tolower);
cout<<s<<endl;
return 0;
}
20 changes: 20 additions & 0 deletions solutions/61A_Ultra_Fast_Mathematician.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include <bits/stdc++.h>
using namespace std;

int main()
{
string a, b;
cin >> a >> b;
string v = "";
for (int i = 0; i < a.length(); i++)
{
if (a[i] == b[i])
v += "0";
else
v += "1";
}
cout << v << endl;
return 0;
}
21 changes: 21 additions & 0 deletions solutions/71A_Way_Too_Long_Words.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int n;
cin>>n;
while(n--){
string s;
cin>>s;
if(s.length()>10){
string ans;
ans.push_back(s.front());
ans+=to_string(s.length()-2);
ans+=s.back();
cout<<ans<<endl;
}else cout<<s<<endl;
}
return 0;
}