Posts

UVA 621

/* ID: Nipun Paul LANG: C++ PROB: God knows */ #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() {     /*ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);*/     ll a;     cin>>a;     for(int i=0; i<a; i++)     {         string b;         cin>>b;         if(b=="1" || b=="4" || b=="78")         {             cout<<"+"<<endl;         }         else if(b[b.size()-1]=='5' && b[b.size()-2]=='3')         {             cout<<"-"<<endl;         }         else if(b[0]=='9' && b[b.size()-1]=='4')         {            ...

UVA 11498

/* ID: Nipun Paul LANG: C++ PROB: God knows */ #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ll a,b,c,d,e;     while(cin>>a)     {         if(a==0)         {             break;         }         cin>>b>>c;         for(int i=0; i<a; i++)         {             cin>>d>>e;             if(d==b || e==c)             {                 cout<<"divisa"<<endl;             }             else if(d>b && e>c)   ...

UVA 10550

/* ID: Nipun Paul LANG: C++ PROB: God knows */ #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ll a,b,c,d;     while(cin>>a>>b>>c>>d)     {         if(a+b+c+d==0)         {             break;         }         ll sum=0,b1=0,c1=0,d1=0;         if(a>=b)         {             a=40+(b+1)-(a+1);             b1=0;         }         else         {             b1=b;         }         if(b<=c)         {     ...

UVA 272

/* ID: Nipun Paul LANG: C++ PROB: God knows */ #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int flag=0;     string a;     while(getline(cin,a))     {         for(int i=0; i<a.size(); i++)         {             if(a[i]=='"' && flag==0)             {                 cout<<"``";                 flag=1;             }             else if(a[i]=='"' && flag==1)             {                 cout<<"''";               ...

Algorithm on how to find the day of a week

https://www.hackerearth.com/blog/developers/how-to-find-the-day-of-a-week/

Prefix sum or for fixed range summation

https://codeforces.com/problemset/problem/433/B https://codeforces.com/problemset/problem/313/B DP catagory solution where accumulate sum not possible in this kind of problem because of test cases and time limit.So if we do sum and insert it in an array previously,just use a vector and subtract from upper trange to lower range we'll get the answer.

Codeforces 295(Div 2) B

https://codeforces.com/problemset/problem/520/B Editorial from blog- Its quite simple . First understand if m<n then ans is n-m  else  make m less than or equal to n by dividing it by 2 , increase the count by one and if at any moment it becomes odd increase the count by 1 and increase m by 1 . e.g  4 17  1. 17->18  2. 18->9  3. 9->10  4. 10->5  5. 5->6  6. 6->3  then 3 is smaller than 4 so ans is 6+(4-3) = 7  * Fully reverse of what the question said to do and have a alternative main solution using  breadth-first search.