nick2k19's blog

By nick2k19, history, 5 years ago, In English

explanation of code

Solution Code

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

By nick2k19, history, 5 years ago, In English

explanation with code

github

Solution Code

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it

By nick2k19, history, 5 years ago, In English

Solution explanation

github link:

#include <bits/stdc++.h>

using namespace std;

int main() {
   int t;
   cin>>t;
   int n;
   int sum;
   int odd;
   int even;
   
   for(int i=0;i<t;i++){
       cin>>n;
       sum=0;
       odd=0;
       even=0;
       int arr[n];
       for(int j=0;j<n;j++){
           cin>>arr[j];
           if(arr[j]%2!=0 || arr[j]==1){
               odd++;
           }else{
               even++;
           }
           sum+=arr[j];
       }
       
       if(sum%2!=0 || sum==1){
           cout<<"YES"<<endl;
       }
       else{
           if(odd!=0 && even!=0){
               cout<<"YES"<<endl;
           }
           else{
               cout<<"NO"<<endl;
           }
       }
   }
   
   
}

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By nick2k19, history, 5 years ago, In English

solution explannation part-1

part-2

GITHUB link [](https://github.com/nick-mehta/codeforces/blob/master/1294A%20codeforces%20problem.cpp)

`#include <bits/stdc++.h>

using namespace std;

int main() { int t; cin>>t; int a,b,c,n;

for(int i=0;i<t;i++){
    cin>>a>>b>>c>>n;



if(a==b && b==c){
    if(n%3==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}
else if (a==b && a>c){
    if(n>=a-c){
        n=n-(a-c);
        if(n%3==0){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
         cout<<"NO"<<endl;
    }
}

 else if (a==b && a<c){
    if(n>=(2*(c-a))){
        n=n-(2*(c-a));
        if(n%3==0 ){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
         cout<<"NO"<<endl;
    }
}

 else if (c==b && b>a){
    if(n>=b-a){
        n=n-(b-a);
        if(n%3==0){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
         cout<<"NO"<<endl;
    }
}

 else if (c==b && b<a){
    if(n>=(2*(a-b))){
        n=n-(2*(a-c));
        if(n%3==0){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
         cout<<"NO"<<endl;
    }
}

 else if (a==c && a>b){
    if(n>=a-b){
        n=n-(a-b);
        if(n%3==0){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
         cout<<"NO"<<endl;
    }
}

 else if (a==c && a<b){
    if(n>=(2*(b-a))){
        n=n-(2*(b-a));
        if(n%3==0){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
         cout<<"NO"<<endl;
    }
}

else{
    if(a>b && a>c){
        if(n>=(a-b)+(a-c)){
            n=n-(a-b)-(a-c);
            if(n%3==0){
                cout<<"YES"<<endl;
            }else{
                cout<<"NO"<<endl;
            }
        }else{
                cout<<"NO"<<endl;
            }

    }
    else if(b>a && b>c){
        if(n>=(b-a)+(b-c)){
            n=n-(b-a)-(b-c);
            if(n%3==0){
                cout<<"YES"<<endl;
            }else{
                cout<<"NO"<<endl;
            }
        }else{
                cout<<"NO"<<endl;
            }

    }
    else if(c>a && c>b){
        if(n>=(c-b)+(c-a)){
            n=n-(c-b)-(c-a);
            if(n%3==0){
                cout<<"YES"<<endl;
            }else{
                cout<<"NO"<<endl;
            }
        }else{
                cout<<"NO"<<endl;
            }

    }

}
}

}`

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By nick2k19, history, 5 years ago, In English

solution explanation

include

using namespace std;

int main() { int n; cin>>n; string s; cin>>s; int x=0; int y=0;

for(int i=0;i<n;i++){
    if(s[i]=='L'){
        x++;
    }else{
        y++;
    }
}

cout<<x+y+1<<endl;

}

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By nick2k19, history, 5 years ago, In English

here you can find solution of problem 1283 b candies division..

SOLUTION

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it