Monday, October 1, 2018

UVa problem solution reverse and add -10018

Discuss: in this problem just simply reverse the digit using very naive process that is also fine. and then whether it is palindrome or not if it is not palindrome then repeat the process for newly create number. you will get your answer,
there is no tricky part  in this problem.

try yourself, before see the code


Saturday, September 29, 2018

UVa problem solution 10523 - Very Easy !!!

problem link:

Discuss: there is many approach to solve this problem. i using java language since it has BigInteger class. if you know java and function of BigInteger then it's very naive problem to you. don't forget to name your class Main(capital M) this is for UVa.

try yourself, before see the code


UVa problem solution 623 - 500!

Problem link:

Discuss: you can solve the problem in many way. but java is naive one. if you know about java BigInteger function and how it works. then just find factorial using any loop. but one thing to cite in uva you must have Class type as Main(M is in capital letter). and there is no tricky part in this problem.


try yourself, before see the code



Friday, September 28, 2018

UVa problem soultion 725 - Division

problem link:

Discuss: this is just simple implementation problem. just simply check every digit using while loop you will get the output.

try yourself, before see the code


Wednesday, September 19, 2018

UVa problem solution 455 - Periodic Strings

problem link:


Discuss: in this problem you can find out longest common sub string using KMP. then trying divide length of string by(length-longest sub) if it's divide than longest sub will be result otherwise there is no result but n.

try yourself, before see the code.

Saturday, September 15, 2018

10298 - Power Strings


10298 - Power Strings

Discuss: this is simple string matching problem. in this problem you have asked to how many reputation you need to make the string. for that i do is create a longest common sequence array. which suffix and also prefix of the string. and if n-l divide n then it can form with this sub string. and the reputation is need n/(n-l). just simple do it.

try yourself,before see the code


Friday, September 14, 2018

10679 - I Love Strings!!

10679 - I Love Strings!!

Discuss: In this problem just simply use KMP pattern searching algorithm. and you will get the result. there  is no tricky part in this problem.
try yourself, before see the code


Thursday, April 12, 2018

UVa problem solution 10931 - Parity

problem link:


Discuss: in this problem you just simply convert decimal to binary. then count the number of one's in binary that will be the 'P'. and for converting you can use c++ built in STL     string binary = std::bitset<31>(n).to_string();   . and there is no tricky part in this problem.

try yourself, before see the code



Friday, April 6, 2018

UVa problem solution 514 - Rails

problem link:

Discuss: in this problem train come from direction A in increasing order and there can many permutation to go direction B. input gives you the permutation to go direction.you can easily check it by using stack.just if top element of stack is less then ith element then push more. if ith element is in stack but not in top then the permutation is impossible



Thursday, April 5, 2018

UVa problem 673 - Parentheses Balance

problem link:

Discuss: This problem i want to solve by counting parentheses before  i know stack. since i know i just laugh at myself. if you know stack then it is just implementation problem for you.there no tricky part in this problem

try yourself before see the code


UVa problem solution 727 - Equation

problem link:

Discuss: in this problem you may first trouble with taking input.it's quite okay it's a terrific one before but it's not like that. you can take input as string and if the first character of string is null character just break the loop.and obviously give a null end of your main string. and other simply need to convert it infix to post fix. if you know stack then it just  a implementation problem for you.

try your self, before see the code



Friday, March 9, 2018

UVa problem solution 10954 - Add All

problem link:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin >>n&&n)
    {
         int i,j,cnt=0,flag=0,a,b,x,sum=0;
        priority_queue<int>que;
        for(i=0;i<n;i++)
        {
            cin >>j;
            j*=-1;
            que.push(j);
        }
        while(que.size()!=1)
        {
            a=que.top();
            que.pop();
            b=que.top();
            que.pop();
            x=(a+b);
            sum+=(x*-1);
            que.push(x);
            if(que.size()==1)
                break;
        }

       cout <<sum<<endl;
    }
    return 0;
}

Wednesday, February 28, 2018

UVa problem solution 11503 - Virtual Friends

problem link:

Discuss: you can solve this problem by simply using disjoint set. just rank the set. and print for every new element. and there is no tricky part. you can use map for using  number instead of string.

try yourself, before see the code



UVa problem solution 10685 - Nature

problem link:

Discuss: you can simply solve this problem using disjoint set. just rank the set by counting the number of element in the set. and you can also use map for using number instead of string. and there is no tricky part in this problem.

try yourself before see the code



UVa problem 459 - Graph Connectivity


problem link:

Discuss: you can solve this problem in many ways like dfs,bfs, disjoint set. i used here disjoint set.just simply put the array element in vector and then erase every duplicate element for in similar set only number exist in vector. the i just count the number of element in the vector. there is also a case where no connectivity among nodes. if use scanf for scan newline than on that case it will not give you any output. so where any problem if need to scan a line only than use getchar() instead of scanf. and there is no more tricky part in this problem.


try your self, before see the code



Saturday, February 24, 2018

UVa problem solution 10608 - Friends

problem link:

Discuss: this is simple disjoint set problem. to solve this problem just use a extra array to store how much element add in a set. for that in make in makeUnion function when you check is the parent to node equal or not.then if not equal then you set ara[x]=y similar way we just count the member of the set also.such m[y]+=m[x] and just print the biggest element of the m array.there is no tricky part in this problem


Saturday, January 27, 2018

UVa problem soultion 1112 - Mice and Maze

problem link:

Discuss: in this problem you can simply use dijksta and solve it.  jut loop through 1 to n and call dijkstra every time.if distant of exit node is less or equal then timer then make count increase. there is no tricky part in this problem.


try yourself , before see the code


Friday, January 26, 2018

UVa problem solution 10986 - Sending email

problem link:

Discuss: in this problem you can simply use dijksta algorithm.if you know the algorithm then this problem just direct implementation of that algroithm. there is no tricky part in this problem

try yourself, before see the code


UVa problem solution 10305 - Ordering Tasks

problem link:

Discuss: you can solve this problem using modified dfs or bfs. we call dfs for every adjacent vertices first.then push every vertex to stack. then just print stack.there is no tricky part in this problem.

try yourself, before see the code


Thursday, January 18, 2018

UVa problem solution 352 - The Seasonal War

problem link:


Discuss: in this problem you to have to find how many disjoint eagle is there.so you can simply use dfs or bfs to solve this problem.when you get a eagle sign and not visited increment count and send it to bfs or dfs function. it will make visited all joint eagle.

try yourself, before see the code


Tuesday, January 16, 2018

UVa problem solution 871 - Counting Cells in a Blob

problem link:

Discuss:this is simple graph problem.you can use bfs to solve.just count how much node visited in a call of bfs function and store it in maximum.you can use getline to take input.and push it to your 2d string and if string is empty just break input.there is no tricky part in this problem

try yourself,before see the code


UVa problem solution 572 - Oil Deposits

problem link:

Discuss: this is simple graph. if you know the fundamental algorithm of graph i mean bfs or dfs then it's pretty easy for you. when you found a node with '@' and it is not visited then just sent the index value to bfs function and increment the answer and in bfs function mark every connected node with it visited. your work done.


try yourself before see the code


Sunday, January 14, 2018

UVa problem solution 10004 - Bicoloring

problem link:

Discuss: if you know bfs algorithm then this problem is fun for you. just do bfs nothing more to do.just first take a color array as like visiting array. convert all number to zero.then in while loop if the color is zero and adjacent node color is then assign it with 2 else 1. and if two adjacent node color same then just break the loop.

try yourself before see the code



UVa problem solution 11470 - Square Sums

problem link:

Discuss: if you know the 2D. then the problem may pretty for you. how i did it first calculate all corner index value.then just increase the value of i and j. and you may trouble how to choose the corner point as it change then use them and analyse  ara[i][j], ara[j][n-1-i], ara[n-1-i][n-1-j], ara[n-1-j][i]  first traverse till n/2 and second loop traverse till n-1-i; examine it . it traverse all the square of the grid. then just print it..


try yourself, before see the code



Friday, January 5, 2018

UVa problem solution 12243 - Flowers Flourish from France

problem link:

Discuss: this is simple implementation problem.you can solve it with just one loop.

try yourself before see the code



UVa problem solution 12527 - Different Digits

problem link:


Discuss: this is simple implementation problem.you can use a bool array to check repeat number.as the range is not so big so you can check every integer individually.

try yourself, before see the code



Thursday, January 4, 2018

UVa problem solution 12592 - Slogan Learning of Princess

problem link:

Discuss: this is simple implementation problem.you can do it with map as well as structure.be careful when taking input. you can use 'getline(cin,string_name)'. and also be careful enough memory declare when use structure else there is run time error.

try yourself,before see the code


UVa problem solution 10812 - Beat the Spread!

problem link:


Discuss: just do the class eight problem.no tricky part in this problem.

try yourself,before see the code


Wednesday, January 3, 2018

UVa problem solution 11988 - Broken Keyboard (a.k.a. Beiju Text)

problem link:

Discuss: this is simple list implementation problem.if you know list then you can it without any trouble. just input the line in a string and then if  '[' in string then change the iterator of string in begin and if you found ']' then change the iterator of string in end.  and else just insert the element in the list.

try your self before see the code



UVa problem solution 10258 - Contest Scoreboard

problem link:

Discuss: though it's a implementation problem.i think pupil coder at least think for some time how to implement. however, you can solve the problem using nested structure.just take input and store in structure and then sort the structure.you can use bubble sort. there is no tricky part in this problem


try yourself,before see the code