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
13 changes: 13 additions & 0 deletions Codeforces/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;
}
19 changes: 19 additions & 0 deletions Codeforces/1328A_Divisibility_Problem.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(){
int t;
cin>>t;
while(t--){
long long a,b;
cin>>a>>b;
if(a%b==0)
cout<<0<<endl;
else{
cout<<b-a%b<<endl;
}
}
return 0;
}
16 changes: 16 additions & 0 deletions Codeforces/1389A_LCM_Problem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
int t;
cin>>t;
while(t--){
int l,r;
cin>>l>>r;
if(2*l>r) cout<<"-1 "<<"-1"<<endl;
else cout<<l<<" "<<2*l<<endl;
}
return 0;
}
20 changes: 20 additions & 0 deletions Codeforces/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;
}
18 changes: 18 additions & 0 deletions Codeforces/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;
}
20 changes: 20 additions & 0 deletions Codeforces/266B_Queue_at_the_School.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform else nknagrale
#include<bits/stdc++.h>
using namespace std;

int main() {
int n,t;
cin>>n>>t;
string a;
cin>>a;
while(t--){
for(int i=0;i<n-1;i++)
if(a[i]=='B' && a[i+1]=='G') {
swap(a[i],a[i+1]);
i++;
}
}
cout<<a<<endl;
return 0;
}
35 changes: 35 additions & 0 deletions Codeforces/271A_Beautiful_Year.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform else nknagrale
#include <bits/stdc++.h>
using namespace std;

bool areDistinct(int n)
{
map<int, int> dis;
int digit;
while (n)
{
digit = n % 10;
if (dis[digit])
{
return false;
}
dis[digit] = 1;
n /= 10;
}
return true;
}
int main()
{
int n;
cin >> n;
while (++n)
{
if (areDistinct(n))
{
cout << n << endl;
break;
}
}
return 0;
}
15 changes: 15 additions & 0 deletions Codeforces/41A_Translation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//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(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 Codeforces/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;
}
13 changes: 13 additions & 0 deletions Codeforces/546A_Soldier_and_Bananas.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(){
long long k,n,w;
cin>>k>>n>>w;
long long sum=((w*(w+1))/2)*k;
if(n>=sum) cout<<0<<endl;
else cout<<sum-n<<endl;
return 0;
}
20 changes: 20 additions & 0 deletions Codeforces/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;
}
11 changes: 11 additions & 0 deletions Codeforces/630A_Again_Twenty_Five!.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(){

long long n;

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

int main(){
int n,h;
cin>>n>>h;
vector<int> v;
int temp;
int ans=0;
for(int i=0;i<n;i++){
cin>>temp;
if(temp>h)
ans+=2;
else ans++;
}
cout<<ans<<endl;
return 0;
}
21 changes: 21 additions & 0 deletions Codeforces/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 else nknagrale
#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;
}
15 changes: 15 additions & 0 deletions Codeforces/977A_Wrong_Subtraction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform else nknagrale
#include<bits/stdc++.h>
using namespace std;

int main(){
int n,k;
cin>>n>>k;
while(k--){
if(n%10==0) n/=10;
else n--;
}
cout<<n<<endl;
return 0;
}
17 changes: 17 additions & 0 deletions Codeforces/996A_Hit_the_Lottery.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//code by Nikhil Nagrale
//nikhilnagrale2 on EveryPlatform
#include<bits/stdc++.h>
using namespace std;

int main(){
long long n;
cin>>n;
int ans=0;
int a[5]={100,20,10,5,1};
for(int x:a){
ans+=n/x;
n%=x;
}
cout<<ans<<endl;
return 0;
}