From 07a0a244c5f69f9e4f2424a5d5b47c0327483f9b Mon Sep 17 00:00:00 2001 From: nikitanagrale <72974891+nikitanagrale@users.noreply.github.com> Date: Fri, 16 Oct 2020 16:58:37 +0530 Subject: [PATCH] added codeforces solutions added 800 rating problems solutions --- solutions/110A_Nearly_Lucky_Number.cpp | 33 ++++++++++++++++++++ solutions/112A_Petya_and_Strings.cpp | 13 ++++++++ solutions/116A_Tram.cpp | 22 +++++++++++++ solutions/136A_Presents.cpp | 24 +++++++++++++++ solutions/141A_Amusing_Joke.cpp | 15 +++++++++ solutions/144A_Arrival_of_the_General.cpp | 36 ++++++++++++++++++++++ solutions/148A_Insomnia_Cure.cpp | 20 ++++++++++++ solutions/155A_I_love_%username.cpp | 29 +++++++++++++++++ solutions/158A_Next_Round.cpp | 22 +++++++++++++ solutions/41A_Translation.cpp | 15 +++++++++ solutions/4A_Watermelon.cpp | 12 ++++++++ solutions/50A_Domino_Piling.cpp | 11 +++++++ solutions/59A_Word.cpp | 19 ++++++++++++ solutions/61A_Ultra_Fast_Mathematician.cpp | 20 ++++++++++++ solutions/71A_Way_Too_Long_Words.cpp | 21 +++++++++++++ 15 files changed, 312 insertions(+) create mode 100644 solutions/110A_Nearly_Lucky_Number.cpp create mode 100644 solutions/112A_Petya_and_Strings.cpp create mode 100644 solutions/116A_Tram.cpp create mode 100644 solutions/136A_Presents.cpp create mode 100644 solutions/141A_Amusing_Joke.cpp create mode 100644 solutions/144A_Arrival_of_the_General.cpp create mode 100644 solutions/148A_Insomnia_Cure.cpp create mode 100644 solutions/155A_I_love_%username.cpp create mode 100644 solutions/158A_Next_Round.cpp create mode 100644 solutions/41A_Translation.cpp create mode 100644 solutions/4A_Watermelon.cpp create mode 100644 solutions/50A_Domino_Piling.cpp create mode 100644 solutions/59A_Word.cpp create mode 100644 solutions/61A_Ultra_Fast_Mathematician.cpp create mode 100644 solutions/71A_Way_Too_Long_Words.cpp diff --git a/solutions/110A_Nearly_Lucky_Number.cpp b/solutions/110A_Nearly_Lucky_Number.cpp new file mode 100644 index 0000000..0924934 --- /dev/null +++ b/solutions/110A_Nearly_Lucky_Number.cpp @@ -0,0 +1,33 @@ +//code by Nikhil Nagrale +//nikhilnagrale2 on EveryPlatform +#include +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"< +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< +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< +using namespace std; + +int main(){ + int n; + cin>>n; + vector v; + for(int i=0;i>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< +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"< +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 +using namespace std; + +int main(){ + int a[4],d; + cin>>a[0]>>a[1]>>a[2]>>a[3]>>d; + int j; + set 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< +using namespace std; + +int main(){ + int n; + cin>>n; + vector v; + for(int i=0;i>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 +using namespace std; + +int main(){ + int n,k; + cin>>n>>k; + vector a; + for(int i=0;i>temp; + a.push_back(temp); + } + int c=a[k-1]; + int count=0; + for(int x:a){ + if(x>=c && x>0) count++; + } + cout< +using namespace std; + +int main(){ + string a,b; + cin>>a>>b; + for(int i=0;i +using namespace std; + +int main(){ + int w; + cin>>w; + if(w%2==0 && w>2) cout<<"YES"< +using namespace std; + +int main(){ + int m,n; + cin>>m>>n; + cout<<(n*m)/2< +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< +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; +} \ No newline at end of file diff --git a/solutions/71A_Way_Too_Long_Words.cpp b/solutions/71A_Way_Too_Long_Words.cpp new file mode 100644 index 0000000..2b71dee --- /dev/null +++ b/solutions/71A_Way_Too_Long_Words.cpp @@ -0,0 +1,21 @@ +//code by Nikhil Nagrale +//nikhilnagrale2 on EveryPlatform +#include +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<