Skip to content
Closed
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 OTHERS/800 Codeforces 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 else nknagrale
#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 OTHERS/800 Codeforces 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 else nknagrale
#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 OTHERS/800 Codeforces 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 else nknagrale
#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 OTHERS/800 Codeforces 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 else nknagrale
#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;
}
36 changes: 36 additions & 0 deletions OTHERS/800 Codeforces 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 OTHERS/800 Codeforces 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;
}
22 changes: 22 additions & 0 deletions OTHERS/800 Codeforces 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 else nknagrale
#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;
}
60 changes: 60 additions & 0 deletions OTHERS/800 Codeforces Solutions/1624A_Plus_One_On_The_Subset.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// code by Susritha
// cf handle:Susritha.S

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
ll a[n],i,j;
ll sus=0;
for(i=0;i<n;i++){
cin>>a[i];
}
for(i=0;i<n;i++){
while(a[i]>n){
a[i]/=2;
}
}
sort(a,a+n);
map<ll,ll>m;
for(i=0;i<n;i++){
if(m[a[i]]==0){
m[a[i]]++;
}
else{
while(a[i]>0){
if(m[a[i]]==0){
m[a[i]]++;
break;}
else{
a[i]/=2;
}

}
if(a[i]==0){
sus=1;
break;
}
}
}
for(auto it=m.begin();it!=m.end();it++){
if(it->second==0){
sus=1;
break;
}
}
if(sus==0){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
}
18 changes: 18 additions & 0 deletions OTHERS/800 Codeforces Solutions/200B_Drinks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int n;
cin>>n;
double a[n];
double ans=0;
for(int i=0;i<n;i++){
cin>>a[i];
ans+=a[i];
}
cout<<ans/n<<endl;

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include <bits/stdc++.h>
using namespace std;

int main()
{
set<long long> s;
int temp;
int t = 4;
while (t--)
{
cin >> temp;
s.insert(temp);
}
cout<<4-s.size()<<endl;
return 0;
}
17 changes: 17 additions & 0 deletions OTHERS/800 Codeforces Solutions/231A_Team.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform else nknagrale
#include<bits/stdc++.h>
using namespace std;

int main(){
int n;
cin>>n;
int count=0;
while(n--){
int x,y,z;
cin>>x>>y>>z;
if((x+y+z)>=2) count++;
}
cout<<count<<endl;
return 0;
}
14 changes: 14 additions & 0 deletions OTHERS/800 Codeforces Solutions/236A_Boy_or_Girl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform else nknagrale
#include<bits/stdc++.h>
using namespace std;

int main(){
string s;
cin>>s;
set<char> a;
for(char x:s) a.insert(x);
if(a.size()%2==0) cout<<"CHAT WITH HER!"<<endl;
else cout<<"IGNORE HIM!"<<endl;
return 0;
}
36 changes: 36 additions & 0 deletions OTHERS/800 Codeforces Solutions/262A_Roma_LuckyNumbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Problem: A. Roma and Lucky Numbers
// Contest: Codeforces - Codeforces Round #160 (Div. 2)
// URL: https://codeforces.com/contest/262/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST1 ios_base::sync_with_stdio(false);
#define FAST2 cin.tie(NULL);
int n, k, ans, num;
string s;
int main(){
FAST1;
FAST2;

cin >> n >> k;
for (int i = 0; i < n; i++){
cin >> s;
for (int j = 0; j < s.size(); j++){
if (s[j] == '7' || s[j] == '4'){
num ++;
}
}
if (num <= k){
ans++;
}
num = 0;
}
cout << ans << endl;
return 0;

}
39 changes: 39 additions & 0 deletions OTHERS/800 Codeforces Solutions/262B_Roma_and_Changing_Signs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Problem: B. Roma and Changing Signs
// Contest: Codeforces - Codeforces Round #160 (Div. 2)
// URL: https://codeforces.com/contest/262/problem/B
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST1 ios_base::sync_with_stdio(false);
#define FAST2 cin.tie(NULL);


int main(){
FAST1;
FAST2;
int n;int k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];

int mn =INT_MAX;
int sm=0;
for(int i=0;i<n;i++)
{
mn = min(abs(arr[i]),mn);
if(arr[i]<0 && k>0)
arr[i] *= -1,k--;
sm+=arr[i];
}
if(k>0 && k%2==1)
sm -= 2 * mn;

cout<<sm;
return 0;
}
Loading