<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-1166892643301539141</atom:id><lastBuildDate>Fri, 08 Nov 2024 15:40:15 +0000</lastBuildDate><category>ACM Algorithms</category><category>Volume 119</category><category>Volume C</category><category>Volume CXIV</category><category>Volume CXVII</category><category>Volume CIII</category><category>Volume IV</category><category>Volume V</category><category>Volume CI</category><category>Volume CXV</category><category>Volume CIX</category><category>Volume CXI</category><category>Programming Books</category><category>Volume 118</category><category>Volume CXVI</category><category>Volume I</category><category>Volume VI</category><category>Volume 120</category><category>Volume CV</category><category>Volume CX</category><category>Volume CXIII</category><category>Volume III</category><category>Volume VII</category><category>Volume CII</category><category>Volume CIV</category><category>Volume CVI</category><category>Volume CVII</category><category>Volume II</category><category>Volume VIII</category><category>Volume XII</category><category>Programming articles</category><category>Volum 124</category><category>Volum 125</category><category>Volume 123</category><category>Volume 124</category><category>Volume 126</category><category>Volume 128</category><category>Volume CVIII</category><category>Volume CXII</category><category>Volume IX</category><category>Volume XI</category><title>ACM Problem Solution</title><description>This blog provides acm problem solution, uva problem solution, Algorithms, Tutorials, Programming resource and some Articles.</description><link>http://acmproblemsolution.blogspot.com/</link><managingEditor>noreply@blogger.com (Unknown)</managingEditor><generator>Blogger</generator><openSearch:totalResults>203</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><language>en-us</language><itunes:explicit>no</itunes:explicit><copyright>Copy Rights by ACM Problem Solution</copyright><itunes:image href="http://3.bp.blogspot.com/_4HKUHirY_2U/S209s4_wFoI/AAAAAAAAAww/8VovLp1Yxlg/EmailRSS.png"/><itunes:keywords>acm,acm,problem,solution,acm,solution,solution,solution,of,uva,uva,problem,uva,problem,solution,uva,solution,algorithm,tutorial,programming,book,articles,c,c</itunes:keywords><itunes:summary>This blog provides acm problem solution , Algorithms, Tutorials, Programming resource and some Articles.</itunes:summary><itunes:subtitle>This blog provides acm problem solution , Algorithms, Tutorials, Programming resource and some Articles.</itunes:subtitle><itunes:category text="Education"><itunes:category text="Language Courses"/></itunes:category><itunes:author>Shaishab Roy</itunes:author><itunes:owner><itunes:email>noreply@blogger.com</itunes:email><itunes:name>Shaishab Roy</itunes:name></itunes:owner><xhtml:meta content="noindex" name="robots" xmlns:xhtml="http://www.w3.org/1999/xhtml"/><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-8017753072256462589</guid><pubDate>Mon, 04 Sep 2017 18:13:00 +0000</pubDate><atom:updated>2019-06-26T22:44:21.575+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ACM Algorithms</category><title>Solution technique of 10684- The jckpot</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;strong&gt;Problem Description&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:&amp;nbsp;https://uva.onlinejudge.org/external/106/10684.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;strong&gt;Solving Technique:&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;This is a maximum subarray&amp;nbsp;summation related problem. We have to find the maximum subarray from a one-dimensional array and sum-up all values of sub array then we will get the&amp;nbsp;&lt;span class="fontstyle01"&gt;&lt;span style="font-size: 11pt;"&gt;patterns of consecutive&lt;/span&gt;&lt;/span&gt;&lt;span style="color: black; font-family: &amp;quot;lmroman10-regular-identity-h&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 11pt;"&gt;&amp;nbsp;&lt;span class="fontstyle01"&gt;wins that will give&amp;nbsp;&lt;/span&gt;&lt;/span&gt;maximum benefit&lt;span class="fontstyle01"&gt;&lt;span style="font-size: 11pt;"&gt;&amp;nbsp;and elaborate a win-win strategy.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Using Kadane’s&lt;/b&gt;&amp;nbsp;algorithm&amp;nbsp;we can solve in O(n) time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Kadane’s Algorithm:&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;Initialize:
    sum = 0
    maxSum = 0

Loop for each element of the array
   sum += array[i]
   if(sum &amp;lt; 0)
     sum = 0
   if(maxSum &amp;lt; sum)
     maxSum = sum
return maxSum&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"&gt;
&lt;span style="font-family: &amp;quot;courier new&amp;quot;; font-size: 10pt;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"&gt;
In this algorithm, if the sum of array elements become 0 or negative then we should set the sum&amp;nbsp;to zero. That means we didn’t want to take any previous elements and we will be finding the next sequence. If we keep negative sum then we will never have the correct answer.&lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"&gt;
&lt;span style="font-family: &amp;quot;courier new&amp;quot;; font-size: 10pt;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 6;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;Example:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;5&lt;br /&gt;12 -4 -10 4 9&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;In this example sum up from the first element to -10 we got -2 and then if we add 4, 9 to the current sum -2 the max value is&amp;nbsp;11. But we could get a better result by discarding all previous sums since 12, -4 and -10 produces a negative sum -2. So we discard all previous sums till -10 then adding 4, 9 and we get the max value of 13.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2017/09/solution-technique-of-10684-jckpot.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-4135099528030445837</guid><pubDate>Mon, 04 Sep 2017 17:56:00 +0000</pubDate><atom:updated>2019-06-26T23:05:44.164+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume CVI</category><title>Solution of 10684- The jckpot</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem description:&lt;/b&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:&amp;nbsp;https://uva.onlinejudge.org/external/106/10684.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;As Manuel wants to get rich faster and without too much work, he decided to make a career in gambling.
Initially, he plans to study the gains and losses of players, so that, he can identify patterns of consecutive
wins and elaborate a win-win strategy. But Manuel, as smart as he thinks he is, does not know how to
program computers. So he hired you to write programs that will assist him in elaborating his strategy.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;Your first task is to write a program that identifies the maximum possible gain out of a sequence of
bets. A bet is an amount of money and is either winning (and this is recorded as a positive value), or
losing (and this is recorded as a negative value).&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;/span&gt;

&lt;span style="font-size: small;"&gt;The input set consists of a positive number N ≤ 10000, that gives the length of the sequence, followed
by N integers. Each bet is an integer greater than 0 and less than 1000.
The input is terminated with N = 0.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;&lt;b&gt;Output&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;For each given input set, the output will echo a line with the corresponding solution. If the sequence
shows no possibility to win money, then the output is the message ‘Losing streak.’&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;&lt;b&gt;Sample input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;5&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;12 -4&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;-3 -4&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;9&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;0&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;
Sample output&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;The maximum winning streak is 18.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include&amp;lt;stdio.h&amp;gt;
using namespace std;
static int inputSequence[10002];
int main() {
    static int n, i, sum, maxGain;

    while((scanf("%d", &amp;amp;n))== 1) {
        if(n == 0) {
            break;
        }
        sum =0;
        maxGain = 0;
        for(i=0; i &amp;lt; n; i++) {
            scanf("%d", &amp;amp;inputSequence[i]);
            sum += inputSequence[i];
            if(sum &amp;lt; 0) {
                sum = 0;
            }
            if(sum &amp;gt; maxGain) {
                maxGain = sum;
            }
        }
        if(maxGain &amp;gt; 0) {
            printf("The maximum winning streak is %d.\n", maxGain);
        } else {
            printf("Losing streak.\n");
        }
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2017/09/solution-of-10684-jckpot.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-477484805930284844</guid><pubDate>Thu, 24 Aug 2017 11:04:00 +0000</pubDate><atom:updated>2017-08-26T14:34:44.417+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume VII</category><title>Solution technique of UVA problem 727 Equqtion </title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;Problem description:&lt;/b&gt;&lt;br /&gt;
&lt;br style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;" /&gt;
&lt;span style="background-color: white; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif; font-size: 13.2px;"&gt;Write a program that changes an infix expression to a postfix expression according to the following specifications.&lt;/span&gt;&lt;br /&gt;
&lt;br style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;" /&gt;
&lt;b style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;&amp;nbsp;Input condition:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;li style="margin: 0px 0px 0.25em; padding: 0px;"&gt;&amp;nbsp;The infix expression to be converted is in the input file in the format of one character per line, with a maximum of 50 lines in the file. For example, (3+2)*5 would be in the form: ( 3 + 2 ) * 5&amp;nbsp;&lt;/li&gt;
&lt;li style="margin: 0px 0px 0.25em; padding: 0px;"&gt;&amp;nbsp;The input starts with an integer on a line by itself indicating the number of test cases. Several infix expressions follows, preceded by a blank line.&amp;nbsp;&lt;/li&gt;
&lt;li style="margin: 0px 0px 0.25em; padding: 0px;"&gt;&amp;nbsp;The program will only be designed to handle the binary operators +, -, *, /.&amp;nbsp;&lt;/li&gt;
&lt;li style="margin: 0px 0px 0.25em; padding: 0px;"&gt;&amp;nbsp;The operands will be one digit numerals.&amp;nbsp;&lt;/li&gt;
&lt;li style="margin: 0px 0px 0.25em; padding: 0px;"&gt;The operators * and / have the highest priority. The operators + and - have the lowest priority. Operators at the same precedence level associate from left to right. Parentheses act as grouping symbols that over-ride the operator priorities.&amp;nbsp;&lt;/li&gt;
&lt;li style="margin: 0px 0px 0.25em; padding: 0px;"&gt;&amp;nbsp;Each testcase will be an expression with valid syntax&lt;a name='more'&gt;&lt;/a&gt;&lt;a href="https://www.blogger.com/null" name="more"&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;b&gt;Expected uotput:&lt;/b&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
The output file will have each postfix expression all on one line. Print a blank line between different expressions.&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;b&gt;Sample Input&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
1&amp;nbsp;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
(&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&amp;nbsp;3&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&amp;nbsp;+&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&amp;nbsp;2&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&amp;nbsp;)&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&amp;nbsp;*&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&amp;nbsp;5&amp;nbsp;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;b&gt;Sample Output&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
32+5*&lt;/div&gt;
&lt;div style="background-color: white; font-family: arial, tahoma, helvetica, freesans, sans-serif; text-align: left;"&gt;
&lt;span style="color: #38761d;"&gt;&lt;b&gt;&lt;span style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style="color: #38761d;"&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Solution Technique&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="background-color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"&gt;
&lt;div style="font-size: 13.2px;"&gt;
This is a simple problem. You can solve this problem by using stack.&amp;nbsp;&lt;span style="font-size: 13.2px;"&gt;Just follow this stapes.&lt;/span&gt;&lt;/div&gt;
&lt;div style="font-size: 13.2px;"&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;&amp;nbsp;Get input for test case.&lt;/li&gt;
&lt;li&gt;Get input expression that need to change infix to postfix &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N.B: When you will give input expression follow that one character per line or more. When get empty line then input is complete&lt;/li&gt;
&lt;li&gt;Read the expression from left to right or top to bottom&lt;/li&gt;
&lt;li&gt;if input character is opening bracket or operator then push into stack.&lt;/li&gt;
&lt;li&gt;if input character is digit then print this character.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;if input character is closing bracket then print operator from stack and pop this operator until get opening bracket.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;pop this opening bracket from stack. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N.B: Do not need to insert closing bracket into stack and check next character.&lt;/li&gt;
&lt;li&gt;. This process running until all input are checked.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2017/08/solution-technique-of-uva-problem-727.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-2702555188387239025</guid><pubDate>Wed, 23 Aug 2017 17:47:00 +0000</pubDate><atom:updated>2017-09-04T21:35:18.792+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume VII</category><title>UVA solution 727 Equation</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem description:&lt;/b&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:&amp;nbsp;https://uva.onlinejudge.org/external/7/727.html&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Write a program that changes an infix expression to a postfix expression according to the following
specifications.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;Input condition:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;&amp;nbsp;The infix expression to be converted is in the input file in the format of one character per line,
with a maximum of 50 lines in the file. For example, (3+2)*5 would be in the form:
(
3
+
2
)
*
5&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;The input starts with an integer on a line by itself indicating the number of test cases. Several
infix expressions follows, preceded by a blank line.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;The program will only be designed to handle the binary operators +, -, *, /.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;The operands will be one digit numerals.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The operators * and / have the highest priority. The operators + and - have the lowest priority.
Operators at the same precedence level associate from left to right. Parentheses act as grouping
symbols that over-ride the operator priorities.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Each testcase will be an expression with valid syntax&lt;a name='more'&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;b&gt;Expected uotput:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The output file will have each postfix expression all on one line. Print a blank line between different
expressions.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Sample Input&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;1&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;(&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;3&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;+&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;5&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Sample Output&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #6aa84f;"&gt;32+5*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;cctype&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include&amp;lt;stack&amp;gt;
#include&amp;lt;algorithm&amp;gt;
using namespace std;

int main()
{
    int t, j, i, len,k, length;
    char expr[100];
    char ch[5];
    scanf("%d\n",&amp;amp;t);
    for(j=1;j&amp;lt;=t;j++)
    {
        stack&amp;lt;char&amp;gt; expstack;
        expstack.push('(');
        k=0;
        while(gets(ch))
        {
            len=strlen(ch);
            if (len==0)
                break ;
            else
                expr[k++]=ch[0];
        }
        expr[k++]=')';
        length=k;
        if(j&amp;gt;1)
            printf("\n");
        for(i=0;i&amp;lt;length;i++)
        {
            if(expr[i]=='('|| expr[i]=='+' || expr[i]=='-' || expr[i]=='*' || expr[i]=='/')
            {
                if((expr[i]=='+' || expr[i]=='-') &amp;amp;&amp;amp; (expstack.top()=='*' || expstack.top()=='/' || expstack.top()=='+' || expstack.top()=='-'))
                {
                    while(expstack.top()=='*' || expstack.top()=='/' || expstack.top()=='+' || expstack.top()=='-')
                    {
                        printf("%c",expstack.top());
                        expstack.pop();
                    }
                    expstack.push(expr[i]);
                }
                else if((expr[i]=='*' || expr[i]=='/') &amp;amp;&amp;amp;(expstack.top()=='*' || expstack.top()=='/'))
                {
                        printf("%c",expstack.top());
                        expstack.pop();
                        expstack.push(expr[i]);
                }
                else
                    expstack.push(expr[i]);
           }
           else if(expr[i]==')')
           {
               while(expstack.top()!='(')
                    {
                        printf("%c",expstack.top());
                        expstack.pop();
                    }
                    expstack.pop();
           }
           else
            printf("%c",expr[i]);
        }
        while(!expstack.empty())
        {
            printf("%c",expstack.top());
            expstack.pop();
        }
            printf("\n");
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2017/08/uva-solution-727-equation.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-3535647600233202461</guid><pubDate>Tue, 22 Aug 2017 17:26:00 +0000</pubDate><atom:updated>2017-09-04T22:08:20.284+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume CI</category><title>Solution of 10127 - Ones</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem description:&lt;/b&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:&amp;nbsp;https://uva.onlinejudge.org/external/101/10127.html&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHOCJfUIdA02KWpik3wlPNWhnpanNrB8c5epIyk_cUkIJ_KCCVgCSSkSh8wzs6zRaCT3Nt6ERe3wnorA5tvqpCW6e56WLgE8Io7htg4C31po549gYGG-8iuIaSMCSaAiD69jFd4N6tBrw/s1600/10127.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" data-original-height="433" data-original-width="305" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHOCJfUIdA02KWpik3wlPNWhnpanNrB8c5epIyk_cUkIJ_KCCVgCSSkSh8wzs6zRaCT3Nt6ERe3wnorA5tvqpCW6e56WLgE8Io7htg4C31po549gYGG-8iuIaSMCSaAiD69jFd4N6tBrw/s200/10127.PNG" width="140" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span class="fontstyle0"&gt;Given any integer &lt;/span&gt;&lt;span class="fontstyle2"&gt;0 &lt;/span&gt;&lt;span class="fontstyle3"&gt;≤ &lt;/span&gt;&lt;span class="fontstyle4"&gt;n &lt;/span&gt;&lt;span class="fontstyle3"&gt;≤ &lt;/span&gt;&lt;span class="fontstyle2"&gt;10000 &lt;/span&gt;&lt;span class="fontstyle0"&gt;not divisible by 2 or 5, some multiple of &lt;/span&gt;&lt;span class="fontstyle4"&gt;n &lt;/span&gt;&lt;span class="fontstyle0"&gt;is a number which in decimal notation is a sequence of &lt;/span&gt;&lt;span class="fontstyle5"&gt;1&lt;/span&gt;&lt;span class="fontstyle0"&gt;’s. How many digits are in the smallest such a multiple of &lt;/span&gt;&lt;span class="fontstyle4"&gt;n&lt;/span&gt;&lt;span class="fontstyle0"&gt;?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fontstyle0"&gt;&lt;b&gt;Input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="fontstyle0"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="fontstyle1"&gt;A fle of integers at one integer per line.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fontstyle0"&gt;&lt;b&gt;Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="fontstyle0"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="fontstyle0"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="fontstyle1"&gt;Each output line gives the smallest integer &lt;/span&gt;&lt;span class="fontstyle3"&gt;x &amp;gt; &lt;/span&gt;&lt;span class="fontstyle4"&gt;0 &lt;/span&gt;&lt;span class="fontstyle1"&gt;such that &lt;/span&gt;&lt;span class="fontstyle3"&gt;p &lt;/span&gt;&lt;span class="fontstyle4"&gt;= &lt;/span&gt;&lt;span class="fontstyle5"&gt;∑&lt;/span&gt;&lt;span class="fontstyle6"&gt;x i&lt;/span&gt;&lt;span class="fontstyle7"&gt;=0 &lt;/span&gt;&lt;span class="fontstyle8"&gt;-&lt;/span&gt;&lt;span class="fontstyle7"&gt;1 &lt;/span&gt;&lt;span class="fontstyle4"&gt;1 &lt;/span&gt;&lt;span class="fontstyle9"&gt;× &lt;/span&gt;&lt;span class="fontstyle4"&gt;10&lt;/span&gt;&lt;span class="fontstyle6"&gt;i &lt;/span&gt;&lt;span class="fontstyle4"&gt;= &lt;/span&gt;&lt;span class="fontstyle3"&gt;a &lt;/span&gt;&lt;span class="fontstyle9"&gt;× &lt;/span&gt;&lt;span class="fontstyle3"&gt;b&lt;/span&gt;&lt;span class="fontstyle1"&gt;, where &lt;/span&gt;&lt;span class="fontstyle3"&gt;a &lt;/span&gt;&lt;span class="fontstyle1"&gt;is the corresponding input integer, and &lt;/span&gt;&lt;span class="fontstyle3"&gt;b &lt;/span&gt;&lt;span class="fontstyle1"&gt;is an integer greater than zero.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class="fontstyle0"&gt;&lt;b&gt;Sample Input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="fontstyle0"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="fontstyle2" style="color: #6aa84f;"&gt;37&lt;br /&gt;9901&lt;/span&gt;&lt;br /&gt;
&lt;span class="fontstyle2"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="fontstyle0"&gt;&lt;b&gt;Sample Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="fontstyle0"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="fontstyle2" style="color: #6aa84f;"&gt;36&lt;br /&gt;12&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;

using namespace std;

int main()
{
    int input,k,one,dividend;
    while(scanf("%d",&amp;amp;input)==1)
    {
        dividend=1;
        one=1;
        if(input==0)
            printf("0\n");
        else
        {
            do{
                if(dividend&amp;lt;input)
                {
                    dividend=(dividend*10)+1;
                    one+=1;
                }
                k=dividend%input;
                if(k!=0)
                    dividend=k;
            }while(k!=0);
            printf("%d\n",one);
        }

    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2017/08/solution-of-10127-ones.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHOCJfUIdA02KWpik3wlPNWhnpanNrB8c5epIyk_cUkIJ_KCCVgCSSkSh8wzs6zRaCT3Nt6ERe3wnorA5tvqpCW6e56WLgE8Io7htg4C31po549gYGG-8iuIaSMCSaAiD69jFd4N6tBrw/s72-c/10127.PNG" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-5518876496579323158</guid><pubDate>Sun, 08 Nov 2015 10:36:00 +0000</pubDate><atom:updated>2017-09-04T21:40:19.688+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume 128</category><title>Solution of 12895 - Armstrong Number </title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: large;"&gt;Problem description&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:&amp;nbsp;https://uva.onlinejudge.org/external/128/12895.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu9enJjgZOLvguNvCXZQRoz0-ViJEYFT4jEFddVSnv1NmnG5iyvD4DmzWaa4G_qDwPICY7mL2bF49FLQdYrTojxQT2YK6zIt5H1Ax8o0r4AgyE_a0Agyhd0e88_zQ26cgtZOQQGpqX6Po/s1600/12895.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" data-original-height="311" data-original-width="900" height="138" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu9enJjgZOLvguNvCXZQRoz0-ViJEYFT4jEFddVSnv1NmnG5iyvD4DmzWaa4G_qDwPICY7mL2bF49FLQdYrTojxQT2YK6zIt5H1Ax8o0r4AgyE_a0Agyhd0e88_zQ26cgtZOQQGpqX6Po/s400/12895.PNG" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;b&gt;Input&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The first line of input is an integer, T that determines the number of test cases. Each of the next T
lines contain a positive integer N, where N ≤ 1000000000.&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;Output&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;For each line of input, there will be one line of output. If N is an Armstrong number print ‘Armstrong’,
otherwise print ‘Not Armstrong’ (without the quotes).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Sample Input&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;3&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;153&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;2732&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;54748&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Sample Output&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Armstrong&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Not Armstrong&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Armstrong&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
#include&amp;lt;math.h&amp;gt;

using namespace std;

int main() {
    int i, t, n, ArmN, ArmNumbuer, digit;
    while(scanf("%d",&amp;amp;t)==1) {
        for(i=0; i&amp;lt;t; i++) {
            scanf("%d", &amp;amp;ArmN);
            ArmNumbuer = ArmN;
            n = 0;
            while(ArmN &amp;gt; 0) {
                ArmN /= 10;
                n+=1;
            }
            ArmN = ArmNumbuer;
            while(ArmN &amp;gt; 0) {
                digit = ArmN % 10;
                ArmN /= 10;
                ArmNumbuer -= pow(digit, n);
            }
            if(ArmNumbuer == 0)
                printf("Armstrong\n");
            else
                printf("Not Armstrong\n");
        }
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2015/11/solution-of-12895-armstrong-number.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu9enJjgZOLvguNvCXZQRoz0-ViJEYFT4jEFddVSnv1NmnG5iyvD4DmzWaa4G_qDwPICY7mL2bF49FLQdYrTojxQT2YK6zIt5H1Ax8o0r4AgyE_a0Agyhd0e88_zQ26cgtZOQQGpqX6Po/s72-c/12895.PNG" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-366857763301395105</guid><pubDate>Sun, 12 Oct 2014 19:01:00 +0000</pubDate><atom:updated>2017-08-24T23:38:43.788+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ACM Algorithms</category><title>Algorithm of 12608 - Garbage Collection</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: large;"&gt;&lt;a href="http://uva.onlinejudge.org/external/126/12608.html" target="_blank"&gt;Problem Description Link&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Algorithm&lt;/span&gt;&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;This is a simple problem this problem you can solve
easily . To solve this problem you must remember 3 conditions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;Garbage truck is
collecting garbage on its route starting at the dump and collecting garbage
from pick up points in order (closest first). Garbage truck returns to the dump
and empties its contents if it either&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start="1" type="1"&gt;
&lt;li class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt;"&gt;is full or&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt;"&gt;cannot load the garbage at the current point because it
     will put the load over the weight limit (the truck driver has no way of
     knowing the weight of the garbage at a particular pick up point until the
     truck reaches that point) or&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt;"&gt;there are no more pick up points left&lt;a name='more'&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;when you return to dump
you need 2 time distance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;For example &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;3 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;1 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;2 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;3 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;In
this example the truck can load 3 ton and 3 points .&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiNklY4deP7WMkTVur0K-8FRg81piVWjfsugsuNm1RkBjm-r3cFmxWKTY1woTMqUhbnhGDRptCX8EeizAEsaNsBE7Jxnx9Ts-iZAh_9bWHl572M8YF5ymxy5Hx1w1pbOU-XCLolynsmxc/s1600/1.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiNklY4deP7WMkTVur0K-8FRg81piVWjfsugsuNm1RkBjm-r3cFmxWKTY1woTMqUhbnhGDRptCX8EeizAEsaNsBE7Jxnx9Ts-iZAh_9bWHl572M8YF5ymxy5Hx1w1pbOU-XCLolynsmxc/s1600/1.PNG" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;First step :&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;!--[if gte vml 1]&gt;&lt;v:group id="_x0000_s1048" style='position:absolute;
 margin-left:29.25pt;margin-top:40.65pt;width:266.25pt;height:36.75pt;
 z-index:251675648' coordorigin="2025,13185" coordsize="5325,735"&gt;
 &lt;v:group id="_x0000_s1049" style='position:absolute;left:2025;top:13185;
  width:5325;height:735' coordorigin="2025,13185" coordsize="5325,735"&gt;
  &lt;v:group id="_x0000_s1050" style='position:absolute;left:2025;top:13185;
   width:5325;height:435' coordorigin="1500,10161" coordsize="5325,435"&gt;
   &lt;v:rect id="_x0000_s1051" style='position:absolute;left:1500;top:10161;
    width:525;height:300' fillcolor="#f79646 [3209]" strokecolor="#f2f2f2 [3041]"
    strokeweight="3pt"&gt;
    &lt;v:shadow on="t" type="perspective" color="#974706 [1609]" opacity=".5"
     offset="1pt" offset2="-1pt"/&gt;
   &lt;/v:rect&gt;&lt;v:shape id="_x0000_s1052" type="#_x0000_t32" style='position:absolute;
    left:2025;top:10356;width:1485;height:15;flip:y' o:connectortype="straight"/&gt;
   &lt;v:shape id="_x0000_s1053" type="#_x0000_t32" style='position:absolute;
    left:3510;top:10161;width:0;height:435' o:connectortype="straight"/&gt;
   &lt;v:shape id="_x0000_s1054" type="#_x0000_t32" style='position:absolute;
    left:3510;top:10341;width:1485;height:15;flip:y' o:connectortype="straight"/&gt;
   &lt;v:shape id="_x0000_s1055" type="#_x0000_t32" style='position:absolute;
    left:4995;top:10161;width:0;height:435' o:connectortype="straight"/&gt;
   &lt;v:shape id="_x0000_s1056" type="#_x0000_t32" style='position:absolute;
    left:4995;top:10341;width:1680;height:0' o:connectortype="straight"/&gt;
   &lt;v:oval id="_x0000_s1057" style='position:absolute;left:6675;top:10161;
    width:150;height:300'/&gt;
  &lt;/v:group&gt;&lt;v:shape id="_x0000_s1058" type="#_x0000_t32" style='position:absolute;
   left:2640;top:13695;width:2880;height:0' o:connectortype="straight"&gt;
   &lt;v:stroke endarrow="block"/&gt;
  &lt;/v:shape&gt;&lt;v:shape id="_x0000_s1059" type="#_x0000_t32" style='position:absolute;
   left:2640;top:13920;width:2880;height:0;flip:x' o:connectortype="straight"&gt;
   &lt;v:stroke endarrow="block"/&gt;
  &lt;/v:shape&gt;&lt;/v:group&gt;&lt;v:shape id="_x0000_s1060" type="#_x0000_t32" style='position:absolute;
  left:2640;top:13695;width:1395;height:0' o:connectortype="straight"&gt;
  &lt;v:stroke endarrow="block"/&gt;
 &lt;/v:shape&gt;&lt;/v:group&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;span style="height: 57px; margin-left: 37px; margin-top: 52px; mso-ignore: vglayout; position: absolute; width: 358px; z-index: 251675648;"&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;Go
to point 1 take garbage&amp;nbsp; then go to point
2 but don’t take garbage because of overload weight so go back to dump and &lt;/span&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt; line-height: 115%;"&gt;empties its contents .
distance for one time=2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYn7Zexwl-zeYVe-dXibVTAkj4wNp2G7rdhHXWz6S-_9TFS9CRp36bTavs4K7jgmS71fDyggJMDJku7s8uE2XChyphenhyphenSAu_G1ArCjPvY8EpfYRZpiaaui7BSo-Dn5VhVvYI0szZRfztwEoGY/s1600/2.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="56" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYn7Zexwl-zeYVe-dXibVTAkj4wNp2G7rdhHXWz6S-_9TFS9CRp36bTavs4K7jgmS71fDyggJMDJku7s8uE2XChyphenhyphenSAu_G1ArCjPvY8EpfYRZpiaaui7BSo-Dn5VhVvYI0szZRfztwEoGY/s1600/2.PNG" width="400" /&gt;&lt;/a&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;Second step: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;Again go to point 2 and
take garbage then go to point 3 and take garbage because no over load &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;So distance for one way
for second stapes= 3 and return to dump &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align="left" cellpadding="0" cellspacing="0"&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td height="30" width="74"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="MsoNormal"&gt;
&lt;!--[if gte vml 1]&gt;&lt;v:group id="_x0000_s1034"
 style='position:absolute;margin-left:57pt;margin-top:24.15pt;width:266.25pt;
 height:36.75pt;z-index:251673600' coordorigin="2580,3450" coordsize="5325,735"&gt;
 &lt;v:group id="_x0000_s1035" style='position:absolute;left:2580;top:3450;
  width:5325;height:735' coordorigin="2025,13185" coordsize="5325,735"&gt;
  &lt;v:group id="_x0000_s1036" style='position:absolute;left:2025;top:13185;
   width:5325;height:435' coordorigin="1500,10161" coordsize="5325,435"&gt;
   &lt;v:rect id="_x0000_s1037" style='position:absolute;left:1500;top:10161;
    width:525;height:300' fillcolor="#f79646 [3209]" strokecolor="#f2f2f2 [3041]"
    strokeweight="3pt"&gt;
    &lt;v:shadow on="t" type="perspective" color="#974706 [1609]" opacity=".5"
     offset="1pt" offset2="-1pt"/&gt;
   &lt;/v:rect&gt;&lt;v:shape id="_x0000_s1038" type="#_x0000_t32" style='position:absolute;
    left:2025;top:10356;width:1485;height:15;flip:y' o:connectortype="straight"/&gt;
   &lt;v:shape id="_x0000_s1039" type="#_x0000_t32" style='position:absolute;
    left:3510;top:10161;width:0;height:435' o:connectortype="straight"/&gt;
   &lt;v:shape id="_x0000_s1040" type="#_x0000_t32" style='position:absolute;
    left:3510;top:10341;width:1485;height:15;flip:y' o:connectortype="straight"/&gt;
   &lt;v:shape id="_x0000_s1041" type="#_x0000_t32" style='position:absolute;
    left:4995;top:10161;width:0;height:435' o:connectortype="straight"/&gt;
   &lt;v:shape id="_x0000_s1042" type="#_x0000_t32" style='position:absolute;
    left:4995;top:10341;width:1680;height:0' o:connectortype="straight"/&gt;
   &lt;v:oval id="_x0000_s1043" style='position:absolute;left:6675;top:10161;
    width:150;height:300'/&gt;
  &lt;/v:group&gt;&lt;v:shape id="_x0000_s1044" type="#_x0000_t32" style='position:absolute;
   left:2640;top:13695;width:2880;height:0' o:connectortype="straight"&gt;
   &lt;v:stroke endarrow="block"/&gt;
  &lt;/v:shape&gt;&lt;v:shape id="_x0000_s1045" type="#_x0000_t32" style='position:absolute;
   left:2640;top:13920;width:2880;height:0;flip:x' o:connectortype="straight"&gt;
   &lt;v:stroke endarrow="block"/&gt;
  &lt;/v:shape&gt;&lt;/v:group&gt;&lt;v:shape id="_x0000_s1046" type="#_x0000_t32" style='position:absolute;
  left:6075;top:3960;width:1830;height:0' o:connectortype="straight"&gt;
  &lt;v:stroke endarrow="block"/&gt;
 &lt;/v:shape&gt;&lt;v:shape id="_x0000_s1047" type="#_x0000_t32" style='position:absolute;
  left:6075;top:4185;width:1830;height:0;flip:x' o:connectortype="straight"&gt;
  &lt;v:stroke endarrow="block"/&gt;
 &lt;/v:shape&gt;&lt;/v:group&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;



&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfX8U9_A0ZUsztvOmzM4OUyuqcpK-UDtqrl32kX3tUOgOG3JQHsiD0-kE6cXfzSXOUGKes27Xk22Y9lA0QMLbZDpy5Cv_8QBA5OTdxM9YtNodVzd0TRHBM2xCJ6-4bqqUlaFysMHXOPXQ/s1600/3.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="70" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfX8U9_A0ZUsztvOmzM4OUyuqcpK-UDtqrl32kX3tUOgOG3JQHsiD0-kE6cXfzSXOUGKes27Xk22Y9lA0QMLbZDpy5Cv_8QBA5OTdxM9YtNodVzd0TRHBM2xCJ6-4bqqUlaFysMHXOPXQ/s1600/3.PNG" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br clear="ALL" /&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;So total one way distance for all stapes= 2+3 =5&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;Each time need back to dump&amp;nbsp; so total distance= 5*2 =10&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;So 10 is final result.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
&lt;span class="apple-style-span"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 12pt; line-height: 115%;"&gt;e.g. this
is not allowed: get a portion of garbage at some point until truck is full and
come back for the rest and same operation perform when truck is full.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;times new roman&amp;quot; , &amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/10/algorithm-of-12608-garbage-collection.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiNklY4deP7WMkTVur0K-8FRg81piVWjfsugsuNm1RkBjm-r3cFmxWKTY1woTMqUhbnhGDRptCX8EeizAEsaNsBE7Jxnx9Ts-iZAh_9bWHl572M8YF5ymxy5Hx1w1pbOU-XCLolynsmxc/s72-c/1.PNG" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-8502372947803046934</guid><pubDate>Sun, 12 Oct 2014 18:49:00 +0000</pubDate><atom:updated>2017-09-04T21:49:06.965+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume 126</category><title>12608 - Garbage Collection</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;b&gt;Problem Descriptin&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;span style="font-size: xx-small;"&gt;source:&lt;/span&gt;https://uva.onlinejudge.org/external/126/12608.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbtrRd1cXnhbJfuIUIlPENJ0bO-QpI1_EEIGIObU0WuKaYDgSnx3GP7IGXoqCG9fhT6tiLMi3hxT4K29bkjjARIzAvAVOJraKrpiPGOpG5kvF1OM6B33C9kRa_5_DLizoZ8xVaGi5-ORY/s1600/12608.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" data-original-height="205" data-original-width="307" height="133" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbtrRd1cXnhbJfuIUIlPENJ0bO-QpI1_EEIGIObU0WuKaYDgSnx3GP7IGXoqCG9fhT6tiLMi3hxT4K29bkjjARIzAvAVOJraKrpiPGOpG5kvF1OM6B33C9kRa_5_DLizoZ8xVaGi5-ORY/s200/12608.PNG" width="200" /&gt;&lt;/a&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;Garbage truck is collecting garbage on its route
starting at the dump and collecting garbage from
pick up points in order (closest first). Garbage
truck returns to the dump and empties its contents
if it either&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;is full or&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;cannnot load the garbage at the current
point because it will put the load over the
weight limit (the truck driver has no way
of knowing the weight of the garbage at
a particular pick up point until the truck
reaches that point) or&amp;nbsp;&lt;/li&gt;
&lt;li&gt;there are no more pick up points left&amp;nbsp;&lt;a name='more'&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;span style="font-size: small;"&gt;The pick up run ends when the truck returns to the dump after the case #3. In the case where
both rule #1 and rule #3 apply, we consider only the latter one (the run is over). Also
note that there are no partial pick ups (e.g. this is not allowed: get a portion of garbage
at some point until truck is full and come back for the rest).&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;Given the weight limit that truck can carry and the list of pick up points with garbage weights,
what is the distance that the truck will cover following the rules above?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;&lt;b&gt;Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;Input starts with an integer T on the first line, the number of test cases. Each case starts with the line
with two integers W and N, the weight limit and the number of pick up points, respectively.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;Then N lines follow, each containing integers xi and wi
, the distance from the dump and the weight
of the garbage at the pick up point respectively.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;Constraints are as given: 1 ≤ W ≤ 1000, 1 ≤ N ≤ 1000, 0 &amp;lt; xi ≤ 100, 000, 1 ≤ wi ≤ W. Distances
are distinct and given in order, i.e. for each i &amp;lt; j, xi &amp;lt; xj .&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;&lt;b&gt;Output&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;For each test case output an integer on a line — the distance covered by the garbage truck.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;&lt;b&gt;Sample Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;3&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;2 2&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;1 1&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;2 2&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;6 3&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;1 1&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;2 2&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;3 3&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;3 3&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;1 2&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;2 2&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;3 1&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: small;"&gt;&lt;b&gt;Sample Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;8&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;&amp;nbsp;6&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: small;"&gt;10&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
using namespace std;

int main()
{
    long long int w,n,t,i,j,di,wt,cwt,tdi;
    scanf("%lld",&amp;amp;t);
    for(i=1;i&amp;lt;=t;i++)
    {
        scanf("%lld %lld",&amp;amp;w,&amp;amp;n);
        cwt=0;tdi=0;
        for(j=1;j&amp;lt;=n;j++)
        {
            scanf("%lld %lld",&amp;amp;di,&amp;amp;wt);
            if((cwt+wt)&amp;gt;w)
            {
                tdi+=di;
                cwt=0;
            }
            if((cwt+wt)==w)
            {
                tdi+=di;
                cwt=0;
                di=0;
            }
            else
                cwt+=wt;
        }
        tdi+=di;
        printf("%lld\n",tdi*2);
    }
    return 0;

}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/10/12608-garbage-collection.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbtrRd1cXnhbJfuIUIlPENJ0bO-QpI1_EEIGIObU0WuKaYDgSnx3GP7IGXoqCG9fhT6tiLMi3hxT4K29bkjjARIzAvAVOJraKrpiPGOpG5kvF1OM6B33C9kRa_5_DLizoZ8xVaGi5-ORY/s72-c/12608.PNG" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-1056141398148129943</guid><pubDate>Wed, 16 Jul 2014 18:40:00 +0000</pubDate><atom:updated>2017-09-04T21:50:36.239+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volum 125</category><title>Solution of 12578 - 10:6:2</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Problem Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;span style="font-size: small;"&gt;source:&amp;nbsp;https://uva.onlinejudge.org/external/125/12578.html&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;The national flag of Bangladesh is bottle green in color and rectangular in size with the length (L) to
width ratio of 10:6. It bears a red circle on the background of green. It maintains the length (L) to
radius ratio of 5:1 (If the length is 10 then width should be 6 and radius should be 2). The color
in the background represents the greenery of Bangladesh while the red circle symbolizes the rising sun
and the sacrifice of lives in our freedom fight.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSciIaZ1B3FDVkKzBKVMGv4fNtv_nc9R0QZLt3kmNZ5GX4G5V_D1Hkl5p5xqXy5sWHk5A8AdhcjbSFjN9Rn-vev8GlmAtMk1UAUvyaRNLfB_hBoitx9zlBVwNRZw91N-lZjpmB2z7pBlw/s1600/12578.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" data-original-height="210" data-original-width="606" height="138" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSciIaZ1B3FDVkKzBKVMGv4fNtv_nc9R0QZLt3kmNZ5GX4G5V_D1Hkl5p5xqXy5sWHk5A8AdhcjbSFjN9Rn-vev8GlmAtMk1UAUvyaRNLfB_hBoitx9zlBVwNRZw91N-lZjpmB2z7pBlw/s400/12578.PNG" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;First line of input will contain the number of test cases, T ≤ 100. Then there follows T lines, each
containing a positive integer L ≤ 1000, representing length of the flag.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&amp;nbsp;For each test case output is a line with two space separated real numbers containing exactly two digits
after decimal point. Two numbers represent the area of red and green portion respectively.
Note: Pi is considered to be arccos(−1).&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;&amp;nbsp;1&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;&amp;nbsp;10&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Output&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;12.57 47.43&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Solution :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#define PI acos(-1)
using namespace std;

int main()
{
    int t,i;
    double l,w,r,areac, arearec;
    while(scanf("%d",&amp;amp;t)==1)
    {
        for(i=1;i&amp;lt;=t;i++)
        {
            scanf("%lf",&amp;amp;l);
            r=l/5;
            w=(l*6)/10;
            areac=PI*r*r;
            arearec=(l*w)-areac;
            printf("%.2lf %.2lf\n",areac,arearec);
        }
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/07/solution-of-12578-1062.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSciIaZ1B3FDVkKzBKVMGv4fNtv_nc9R0QZLt3kmNZ5GX4G5V_D1Hkl5p5xqXy5sWHk5A8AdhcjbSFjN9Rn-vev8GlmAtMk1UAUvyaRNLfB_hBoitx9zlBVwNRZw91N-lZjpmB2z7pBlw/s72-c/12578.PNG" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-5579318264994722849</guid><pubDate>Mon, 07 Jul 2014 17:25:00 +0000</pubDate><atom:updated>2014-07-07T23:25:01.403+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ACM Algorithms</category><title>Algorithm of 12405 - Scarecrow</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: large;"&gt;&lt;a href="http://uva.onlinejudge.org/external/124/12405.html" target="_blank"&gt;Problem Description Link&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Algorithm:&lt;/span&gt;&lt;br /&gt;
This is a easy problem just you get a string&lt;br /&gt;
scan each character until length of string&lt;br /&gt;
if character is '.' then replace the next character by '#' &amp;nbsp;and&lt;br /&gt;
increase the counter value and set position=position+2;&lt;br /&gt;
some input/output:&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
6&lt;br /&gt;
4&lt;br /&gt;
#.#.&lt;br /&gt;
5&lt;br /&gt;
#.#.#&lt;br /&gt;
5&lt;br /&gt;
#..#.&lt;br /&gt;
11&lt;br /&gt;
...##....##&lt;br /&gt;
5&lt;br /&gt;
#####&lt;br /&gt;
11&lt;br /&gt;
...........&lt;br /&gt;
o/p:&lt;br /&gt;
Case 1: 1&lt;br /&gt;
Case 2: 1&lt;br /&gt;
Case 3: 2&lt;br /&gt;
Case 4: 3&lt;br /&gt;
Case 5: 0&lt;br /&gt;
Case 6: 4&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/07/algorithm-of-12405-scarecrow.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-1661898672782151081</guid><pubDate>Mon, 07 Jul 2014 17:19:00 +0000</pubDate><atom:updated>2017-09-04T22:20:27.273+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume 124</category><title>Solution of 12405 - Scarecrow</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: large;"&gt;Problem Description&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:&amp;nbsp;https://uva.onlinejudge.org/external/124/12405.html&lt;/span&gt;&lt;br /&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKxnOzxDuIemXEzSrxNQ22UarlyqgOou5Y2MNIKag2UKq9ho16aT4bCL4E8wCQuxRYEAX9p0OI7VIgFScUmeXKjzik5DbBs-cxX62RcLDm8hyHstI71uURRFGE2rRhAHKoGyWXwgXOZ3A/s1600/Capture.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" data-original-height="286" data-original-width="278" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKxnOzxDuIemXEzSrxNQ22UarlyqgOou5Y2MNIKag2UKq9ho16aT4bCL4E8wCQuxRYEAX9p0OI7VIgFScUmeXKjzik5DbBs-cxX62RcLDm8hyHstI71uURRFGE2rRhAHKoGyWXwgXOZ3A/s200/Capture.PNG" width="193" /&gt;&lt;/a&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;Taso owns a very long field. He plans to grow different types of
crops in the upcoming growing season. The area, however, is full
of crows and Taso fears that they might feed on most of the crops.
For this reason, he has decided to place some scarecrows at different
locations of the field.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;The field can be modeled as a 1×N grid. Some parts of the field
are infertile and that means you cannot grow any crops on them. A
scarecrow, when placed on a spot, covers the cell to its immediate
left and right along with the cell it is on.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-size: medium;"&gt;Given the description of the field, what is the minimum number
of scarecrows that needs to be placed so that all the useful section
of the field is covered? Useful section refers to cells where crops can
be grown.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing an integer N (0 &amp;lt; N &amp;lt; 100). The next line contains N
characters that describe the field. A dot (.) indicates a crop-growing spot and a hash (#) indicates an
infertile region.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&amp;nbsp;For each case, output the case number first followed by the number of scarecrows that need to be
placed.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="background-color: white; color: #6aa84f;"&gt;&lt;span style="color: #333333; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;"&gt;2&lt;/span&gt;&lt;br style="font-family: &amp;quot;lucida grande&amp;quot;, &amp;quot;trebuchet ms&amp;quot;, verdana, helvetica, arial, sans-serif;" /&gt;&lt;span style="color: #333333; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;"&gt;10&lt;/span&gt;&lt;br style="font-family: &amp;quot;lucida grande&amp;quot;, &amp;quot;trebuchet ms&amp;quot;, verdana, helvetica, arial, sans-serif;" /&gt;&lt;span style="color: #333333; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;"&gt;..#..##...&lt;/span&gt;&lt;br style="font-family: &amp;quot;lucida grande&amp;quot;, &amp;quot;trebuchet ms&amp;quot;, verdana, helvetica, arial, sans-serif;" /&gt;&lt;span style="color: #333333; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;"&gt;13&lt;/span&gt;&lt;br style="font-family: &amp;quot;lucida grande&amp;quot;, &amp;quot;trebuchet ms&amp;quot;, verdana, helvetica, arial, sans-serif;" /&gt;&lt;span style="color: #333333; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;"&gt;..#..##....#.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Output&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #333333; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;"&gt;Case 1: 3&lt;/span&gt;&lt;br style="font-family: &amp;quot;lucida grande&amp;quot;, &amp;quot;trebuchet ms&amp;quot;, verdana, helvetica, arial, sans-serif;" /&gt;&lt;span style="color: #333333; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;"&gt;Case 2: 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: #e1ebf2; color: #333333; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: magenta;"&gt;&lt;span style="background-color: #e1ebf2; font-family: &amp;quot;lucida grande&amp;quot; , &amp;quot;trebuchet ms&amp;quot; , &amp;quot;verdana&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
using namespace std;

int main()
{
    int i,j,len,t,count;
    char ch[105];
    while(scanf("%d",&amp;amp;t)==1)
    {
        for(i=1;i&amp;lt;=t;i++)
        {
            scanf("%d",&amp;amp;len);
               scanf("%s",&amp;amp;ch);

            count=0;
            for(j=0;j&amp;lt;len;j++)
            {
                if(ch[j]=='.')
                {
                    ch[j+1]='#';
                    count+=1;
                    j+=2;
                }
            }
            printf("Case %d: %d\n",i,count);
        }
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/07/solution-of-12405-scarecrow.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKxnOzxDuIemXEzSrxNQ22UarlyqgOou5Y2MNIKag2UKq9ho16aT4bCL4E8wCQuxRYEAX9p0OI7VIgFScUmeXKjzik5DbBs-cxX62RcLDm8hyHstI71uURRFGE2rRhAHKoGyWXwgXOZ3A/s72-c/Capture.PNG" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-6673638010505143089</guid><pubDate>Sun, 06 Jul 2014 17:41:00 +0000</pubDate><atom:updated>2014-07-06T23:41:48.215+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ACM Algorithms</category><title>Algorithm of 11933 - Splitting Numbers</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: large;"&gt;&lt;a href="http://uva.onlinejudge.org/external/119/11933.html" target="_blank"&gt;Problem Description Link&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
Algorithm:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
This is a simple problem the operation of splitting a binary
number n into two numbers a(n), b(n) .&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
you need to convert decimal to binary format for a given
number and from that binary format create two numbers&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
a(n) and b(n). To build first value a(n) need to choice 1&lt;sup&gt;st&lt;/sup&gt;
&amp;nbsp;1&amp;nbsp;
,3&lt;sup&gt;rd&lt;/sup&gt; &amp;nbsp;1, 5&lt;sup&gt;th&lt;/sup&gt;
&amp;nbsp;1,..... so on same position of original
binary format other position fii by the value 0.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
To build second value b(n) need to choice 2&lt;sup&gt;nd&lt;/sup&gt; &amp;nbsp;1&amp;nbsp; ,4&lt;sup&gt;th&lt;/sup&gt;&amp;nbsp; 1, 6&lt;sup&gt;th&lt;/sup&gt; &amp;nbsp;1,..... so on same position of original binary
format other position fill by the value 0.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
for example&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
n=13&lt;/div&gt;
&lt;table align="left" border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; margin-left: 6.75pt; margin-right: 6.75pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-table-anchor-horizontal: page; mso-table-anchor-vertical: paragraph; mso-table-left: 169.35pt; mso-table-lspace: 9.0pt; mso-table-rspace: 9.0pt; mso-table-top: -.1pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr style="height: 13.45pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 48.7pt;" valign="top" width="65"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
1&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 48.7pt;" valign="top" width="65"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
1&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 48.7pt;" valign="top" width="65"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
0&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 48.7pt;" valign="top" width="65"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
1&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="MsoNormal"&gt;
binary format&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; index&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="left" border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; margin-left: 6.75pt; margin-right: 6.75pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-table-anchor-horizontal: page; mso-table-anchor-vertical: paragraph; mso-table-left: 148.35pt; mso-table-lspace: 9.0pt; mso-table-rspace: 9.0pt; mso-table-top: 3.75pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr style="height: 13.45pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 56.95pt;" valign="top" width="76"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
1(3&lt;sup&gt;rd&lt;/sup&gt;
  1)&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 56.95pt;" valign="top" width="76"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
0&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 56.95pt;" valign="top" width="76"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
0&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 56.95pt;" valign="top" width="76"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
1
  (1&lt;sup&gt;st&lt;/sup&gt; 1)&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="MsoNormal"&gt;
For a(n)&amp;nbsp;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="left" border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; margin-left: 6.75pt; margin-right: 6.75pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-table-anchor-horizontal: page; mso-table-anchor-vertical: paragraph; mso-table-left: 142.35pt; mso-table-lspace: 9.0pt; mso-table-rspace: 9.0pt; mso-table-top: 2.35pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr style="height: 13.45pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 59.95pt;" valign="top" width="80"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
0&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 59.95pt;" valign="top" width="80"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
1(2&lt;sup&gt;nd&lt;/sup&gt;
  1)&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 59.95pt;" valign="top" width="80"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
0&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; height: 13.45pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 59.95pt;" valign="top" width="80"&gt;
  &lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
0&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="MsoNormal"&gt;
For b(n)&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
So a= 9 and b=4&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/07/algorithm-of-11933-splitting-numbers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-3686535371061726214</guid><pubDate>Sun, 06 Jul 2014 17:34:00 +0000</pubDate><atom:updated>2017-09-04T22:09:41.109+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume 119</category><title>Solution of 11933 - Splitting Numbers</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: large;"&gt;Problem Description&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:https://uva.onlinejudge.org/external/119/11933.html&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We define the operation of splitting
a binary number n into two numbers
a(n), b(n) as follows. Let 0 ≤ i1 &amp;lt; i2 &amp;lt;
. . . &amp;lt; ik be the indices of the bits (with
the least significant bit having index 0) in
n that are 1. Then the indices of the bits
of a(n) that are 1 are i1, i3, i5, . . . and the
indices of the bits of b(n) that are 1 are
i2, i4, i6, . . .&lt;br /&gt;
For example, if n is 110110101 in binary
then, again in binary, we have a =
010010001 and b = 100100100.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyi6gkqUZ03BX8MYu1sxHqe7SG6gYQCfmfhR0MfDv92ByrAnCu-NCkIIbhXzmR7bdj_hopR1d5AoQ75RxJ7idz4wHjd41_p9W7vnncZ7H3JpXT3mY01ctwIr-B-fFlc8ApXSVFvWPsyTU/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" data-original-height="370" data-original-width="500" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyi6gkqUZ03BX8MYu1sxHqe7SG6gYQCfmfhR0MfDv92ByrAnCu-NCkIIbhXzmR7bdj_hopR1d5AoQ75RxJ7idz4wHjd41_p9W7vnncZ7H3JpXT3mY01ctwIr-B-fFlc8ApXSVFvWPsyTU/s320/Capture.PNG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Input&lt;br /&gt;
&lt;br /&gt;
Each test case consists of a single integer
n between 1 and 231 − 1 written in standard decimal (base 10) format on a single line. Input is
terminated by a line containing ‘0’ which should not be processed.&lt;br /&gt;
&lt;br /&gt;
Output&lt;br /&gt;
&lt;br /&gt;
The output for each test case consists of a single line, containing the integers a(n) and b(n) separated
by a single space. Both a(n) and b(n) should be written in decimal format.&lt;br /&gt;
&lt;br /&gt;
Sample Input&lt;br /&gt;
&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;andale mono&amp;quot; , &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: 11.7px; white-space: pre;"&gt;25
5000
1000000
2000000000
2147483647
0&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Sample Output&lt;br /&gt;
&lt;br /&gt;
&lt;span style="background-color: white; color: #6aa84f; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;andale mono&amp;quot; , &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: 11.7px; white-space: pre;"&gt;17 8
4360 640
671808 328192
1378124800 621875200
1431655765 715827882&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: seagreen; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;andale mono&amp;quot; , &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: 11.7px; white-space: pre;"&gt;&lt;br /&gt;&lt;/span&gt;
Solution:&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
using namespace std;

int main()
{
    int n,even,temp1,c,sum;
    while(scanf("%d",&amp;amp;n)==1)
    {
        if(n==0)
            break;
        temp1=n;
        c=0;even=0;sum=0;
        while(temp1!=0)
        {
            if(temp1%2==1)
            {
                even++;
                if(even%2==1)
                {
                    sum+=pow(2,c);
                }
            }
            temp1/=2;
            c++;
        }
        printf("%d %d\n",sum,n-sum);
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/07/solution-of-11933-splitting-numbers.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyi6gkqUZ03BX8MYu1sxHqe7SG6gYQCfmfhR0MfDv92ByrAnCu-NCkIIbhXzmR7bdj_hopR1d5AoQ75RxJ7idz4wHjd41_p9W7vnncZ7H3JpXT3mY01ctwIr-B-fFlc8ApXSVFvWPsyTU/s72-c/Capture.PNG" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-7970177238364604577</guid><pubDate>Sun, 06 Jul 2014 16:00:00 +0000</pubDate><atom:updated>2017-09-04T22:21:25.268+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume CXV</category><title>Solution of 11559 - Event Planning</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: large;"&gt;Problelm&amp;nbsp;description&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:&amp;nbsp;http://uva.onlinejudge.org/external/115/11559.html&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As you didn’t show up to the yearly general meeting of the Nordic
Club of Pin Collectors, you were unanimously elected to organize
this years excursion to Pin City. You are free to choose from a
number of weekends this autumn, and have to find a suitable hotel
to stay at, preferably as cheap as possible.
You have some constraints: The total cost of the trip must be
within budget, of course. All participants must stay at the same
hotel, to avoid last years catastrophe, where some members got lost
in the city, never being seen again.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFwRYC9ZzIx32-RPZLPtpMofOoUGEM0EBm2HqFjyCLyJLdd5SxLRhTIOptHAM7Lk7xf6Od0TSi-NDSZA9zuef4_ucXy8DRFPkdkTbHaZBasXVLMCDPLuo1NRf6v-y-TG65BhXDxaKv7K8/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" data-original-height="188" data-original-width="188" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFwRYC9ZzIx32-RPZLPtpMofOoUGEM0EBm2HqFjyCLyJLdd5SxLRhTIOptHAM7Lk7xf6Od0TSi-NDSZA9zuef4_ucXy8DRFPkdkTbHaZBasXVLMCDPLuo1NRf6v-y-TG65BhXDxaKv7K8/s200/Capture.PNG" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Input&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The input file contains several test cases, each of them as described
below.
The first line of input consists of four integers: 1 ≤ N ≤ 200, the number of participants, 1 ≤ B ≤
500000, the budget, 1 ≤ H ≤ 18, the number of hotels to consider, and 1 ≤ W ≤ 13, the number
of weeks you can choose between. Then follow two lines for each of the H hotels. The first gives
1 ≤ p ≤ 10000, the price for one person staying the weekend at the hotel. The second contains W
integers, 0 ≤ a ≤ 1000, giving the number of available beds for each weekend at the hotel.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;For each test case, write to the output the minimum cost of the stay for your group, or “stay home”
if nothing can be found within the budget, on a line by itself.&lt;br /&gt;
&lt;div&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;3 1000 2 3&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;200&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;0 2 2&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;300&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;27 3 20&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;5&amp;nbsp;2000 2 4&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;300&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;4 3 0 4&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;450&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;7 8 0 13&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Output&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;900&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;stay home&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: magenta;"&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Solution&lt;/b&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
using namespace std;

int main()
{
    long long int nPerson,budget,hotel,week,price,sit,i,j,flag,cost,tempCost,get;
    //freopen("in.txt","r",stdin);
    while(scanf("%lld %lld %lld %lld",&amp;amp;nPerson, &amp;amp;budget, &amp;amp;hotel, &amp;amp;week)==4)
    {
      cost=500005;get=0;
        for(i=1;i&amp;lt;=hotel;i++)
        {
            flag=0;
            scanf("%lld",&amp;amp;price);
            for(j=1;j&amp;lt;=week;j++)
            {
                scanf("%lld",&amp;amp;sit);
                if(sit&amp;gt;=nPerson)
                    flag=1;
            }
            tempCost=price*nPerson;
            if(flag==1 &amp;amp;&amp;amp; tempCost&amp;lt;=budget &amp;amp;&amp;amp; cost&amp;gt;tempCost)
            {
                cost=tempCost;
                get=1;
            }
        }
        if(get==1)
            printf("%lld\n",cost);
        else
            printf("stay home\n");
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/07/solution-of-11559-event-planning.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFwRYC9ZzIx32-RPZLPtpMofOoUGEM0EBm2HqFjyCLyJLdd5SxLRhTIOptHAM7Lk7xf6Od0TSi-NDSZA9zuef4_ucXy8DRFPkdkTbHaZBasXVLMCDPLuo1NRf6v-y-TG65BhXDxaKv7K8/s72-c/Capture.PNG" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-7499696781262909028</guid><pubDate>Thu, 13 Mar 2014 20:31:00 +0000</pubDate><atom:updated>2014-03-14T02:31:23.217+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ACM Algorithms</category><title>Algorithm of 11407 - Squares</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;a href="http://uva.onlinejudge.org/external/114/11407.html" target="_blank"&gt;Problem Description Link&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;Algorithm&lt;/span&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="MsoNormal"&gt;
This is a simple problem&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;
&lt;/span&gt;to solve this problem you can pre generate the number of minimum terms
for all integer from 1 to 10000 and get input and check from array how
many&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;term needed and print the value.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Process: &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;For any positive
integer &lt;span class="math"&gt;&lt;i&gt;N&lt;/i&gt;&lt;/span&gt; , &lt;span class="math"&gt;&lt;i&gt;N&lt;/i&gt; = &lt;i&gt;a&lt;/i&gt;1&lt;/span&gt;&lt;sup&gt;&lt;span style="mso-no-proof: yes;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75"
 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
 filled="f" stroked="f"&gt;
 &lt;v:stroke joinstyle="miter"/&gt;
 &lt;v:formulas&gt;
  &lt;v:f eqn="if lineDrawn pixelLineWidth 0"/&gt;
  &lt;v:f eqn="sum @0 1 0"/&gt;
  &lt;v:f eqn="sum 0 0 @1"/&gt;
  &lt;v:f eqn="prod @2 1 2"/&gt;
  &lt;v:f eqn="prod @3 21600 pixelWidth"/&gt;
  &lt;v:f eqn="prod @3 21600 pixelHeight"/&gt;
  &lt;v:f eqn="sum @0 0 1"/&gt;
  &lt;v:f eqn="prod @6 1 2"/&gt;
  &lt;v:f eqn="prod @7 21600 pixelWidth"/&gt;
  &lt;v:f eqn="sum @8 21600 0"/&gt;
  &lt;v:f eqn="prod @7 21600 pixelHeight"/&gt;
  &lt;v:f eqn="sum @10 21600 0"/&gt;
 &lt;/v:formulas&gt;
 &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/&gt;
 &lt;o:lock v:ext="edit" aspectratio="t"/&gt;
&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1027" type="#_x0000_t75"
 alt="$\scriptstyle \wedge$" style='width:9.75pt;height:10.5pt;visibility:visible;
 mso-wrap-style:square'&gt;
 &lt;v:imagedata src="file:///C:\Users\shaishab\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif"
  o:title="wedge$"/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img alt="$\scriptstyle \wedge$" height="14" src="file:///C:/Users/shaishab/AppData/Local/Temp/msohtmlclip1/01/clip_image001.gif" v:shapes="Picture_x0020_1" width="13" /&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;/sup&gt;&lt;span class="math"&gt;2 + &lt;i&gt;a&lt;/i&gt;2&lt;/span&gt;&lt;sup&gt;&lt;span style="mso-no-proof: yes;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape
 id="Picture_x0020_2" o:spid="_x0000_i1026" type="#_x0000_t75" alt="$\scriptstyle \wedge$"
 style='width:9.75pt;height:10.5pt;visibility:visible;mso-wrap-style:square'&gt;
 &lt;v:imagedata src="file:///C:\Users\shaishab\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif"
  o:title="wedge$"/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img alt="$\scriptstyle \wedge$" height="14" src="file:///C:/Users/shaishab/AppData/Local/Temp/msohtmlclip1/01/clip_image001.gif" v:shapes="Picture_x0020_2" width="13" /&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;/sup&gt;&lt;span class="math"&gt;2 +...+ &lt;i&gt;an&lt;/i&gt;&lt;/span&gt;&lt;sup&gt;&lt;span style="mso-no-proof: yes;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape
 id="Picture_x0020_3" o:spid="_x0000_i1025" type="#_x0000_t75" alt="$\scriptstyle \wedge$"
 style='width:9.75pt;height:10.5pt;visibility:visible;mso-wrap-style:square'&gt;
 &lt;v:imagedata src="file:///C:\Users\shaishab\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif"
  o:title="wedge$"/&gt;
&lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img alt="$\scriptstyle \wedge$" height="14" src="file:///C:/Users/shaishab/AppData/Local/Temp/msohtmlclip1/01/clip_image001.gif" v:shapes="Picture_x0020_3" width="13" /&gt;&lt;!--[endif]--&gt;&lt;/span&gt;&lt;/sup&gt;&lt;span class="math"&gt;2&lt;/span&gt; that is, any positive integer can be represented as sum of
squares of other numbers.&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For example you know minimum term of 1,2,3,4 and based on
this value calculate others&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;5 to 10000
value term &lt;/div&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.85pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
1&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.85pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
2&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.85pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
3&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.85pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
1&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.9pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
&lt;span style="color: red;"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.9pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
3&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.9pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
4&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.9pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
2&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.9pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
1&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 47.9pt;" valign="top" width="64"&gt;
  &lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;
&lt;span style="color: red;"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="MsoNormal"&gt;
1&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;2&lt;span style="mso-tab-count: 2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;3&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;4&lt;span style="mso-tab-count: 2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;5&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;6&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;7&lt;span style="mso-tab-count: 2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;8&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;9&lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;10&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For 5&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
S=sqrt(5)=2&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Way&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;2&lt;sup&gt;2&lt;/sup&gt;+1&lt;sup&gt;2&lt;/sup&gt;=5
so 2 term&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
And&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;1&lt;sup&gt;2&lt;/sup&gt;+2&lt;sup&gt;2&lt;/sup&gt;=5
so 2 term &lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Min value=2&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
So&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;


&lt;div class="MsoNormal"&gt;
Loop from ( s=2 to 1)&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;array[5- 2*2]+1=2 &lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;because 2&lt;sup&gt;2 &lt;/sup&gt;=4&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;and (5-1)=1&lt;sup&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/sup&gt;we know term of 1=1 so 2&lt;sup&gt;2&lt;/sup&gt; is
1 term and for 1 need 1 term so total term=(1+1)=2&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
array[5- 1*1]+1=2&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;
&lt;/span&gt;because 1&lt;sup&gt;2 &lt;/sup&gt;=1+1&lt;sup&gt;2&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/sup&gt;we
know term of 1=1 so 2&lt;sup&gt;2&lt;/sup&gt; is 1 term and for 1 need 1 term so total
term=(1+1)=2&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
so array[5]=2;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
For 10&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
S=sqrt(10)=3&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Loop from (3 to 1)&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Array[10-3*3]+1=2&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Array[10-2*2]+1=4&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
Array[10-1*1]+1=2&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;so
min =2 so array[10]=2&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/03/algorithm-of-11407-squares.html</link><thr:total>1</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-1955085300786247795</guid><pubDate>Thu, 13 Mar 2014 20:20:00 +0000</pubDate><atom:updated>2017-09-04T22:22:46.917+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume CXIV</category><title>Solution of 11407 - Squares</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;Problem Description&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;source:&amp;nbsp;http://uva.onlinejudge.org/external/114/11407.html&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;For any positive integer N, N = a
2
1 + a
2
2 + . . . + a
2
n that is, any positive integer can be represented as
sum of squares of other numbers.
Your task is to print the smallest ‘n’ such that N = a
2
1 + a
2
2 + . . . + a
2
n.&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;b&gt;Input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;The first line of the input will contain an integer ‘t’ which indicates the number of test cases to follow.
Each test case will contain a single integer ‘N’ (1 ≤ N ≤ 10000) on a line by itself.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Output&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Print an integer which represents the smallest ‘n’ such that N = a
2
1 + a
2
2 + . . . + a
2
n.&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Explanation for sample test cases:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;5 → number of test cases&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;1 = 12
(1 term)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;2 = 12 + 12
(2 terms)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;3 = 12 + 12 + 12
(3 terms)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;4 = 22
(1 term)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;50 = 52 + 52
(2 terms)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Sample Input&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="color: #6aa84f; font-size: medium;"&gt;&amp;nbsp;5
1
2
3
4
50&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Sample Output&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="color: #6aa84f; font-size: medium;"&gt;1
2
3
1&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="color: magenta; font-size: medium;"&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;

using namespace std;

int main()
{
    int i,j,t,n,s,value[10005],c,minValue;
    value[1]=1;value[2]=2;value[3]=3;value[4]=1;
    for(i=5;i&amp;lt;10001;i++)
    {
        s=sqrt(i);
        c=1000;
        for(j=s;j&amp;gt;0;j--)
        {
            minValue=value[i-(j*j)]+1;
            if(c&amp;gt;minValue)
                c=minValue;
        }
        value[i]=c;
    }
    //freopen("in.txt","r",stdin);
    while(scanf("%d",&amp;amp;t)==1)
    {
        for(i=1;i&amp;lt;=t;i++)
        {
            scanf("%d",&amp;amp;n);
            printf("%d\n",value[n]);
        }
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2014/03/solution-of-11219-how-old-are-you.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-3913077972759422392</guid><pubDate>Wed, 20 Nov 2013 14:16:00 +0000</pubDate><atom:updated>2017-09-04T22:24:02.229+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume CXII</category><title>Solution of 11219 - How old are you?</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;b&gt;Problem Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:http://uva.onlinejudge.org/external/112/11219.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
- Here are the filled form.
- Thank you. Let me check... hum... OK, OK, OK... Wait, how old are you?
- 20. Did I forget to fill it?&lt;br /&gt;
- No. It says here that you’ll be born next month! The year is wrong...&lt;br /&gt;
- Oh... Sorry!&lt;br /&gt;
&lt;br /&gt;
The process is going to be automatic and to avoid some human errors there will be a calculated field
that informs the age based in the current date and the birth date given. This is your task, calculate
the age, or say if there’s something wrong.&lt;br /&gt;
&lt;br /&gt;
Input
The first line of input gives the number of cases, T (1 ≤ T ≤ 200). T test cases follow. Each test case
starts with a blank line, then you will have 2 lines corresponding to the current date and the birth date,
respectively. The dates are in the format DD/MM/Y Y Y Y , where DD is the day, MM the month
and Y Y Y Y the year. All dates will be valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;b&gt;Output&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The output is comprised of one line for each input data set and should be as follow (quotes for clarifying
only):&lt;br /&gt;
‘Case #N: AGE’, where N is the number of the current test case and AGE is one of the 3 following
options:&lt;br /&gt;
• ‘Invalid birth date’, if the calculated age is impossible (still going to be born).&lt;br /&gt;
• ‘Check birth date’, if the calculated age is more than 130.&lt;br /&gt;
• the calculated age (years old only), otherwise.&lt;br /&gt;
• If the two dates are the same, the output should be ‘0’.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Sample Inpu&lt;/b&gt;t&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;4
01/01/2007&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;10/02/2007&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f;"&gt;09/06/2007&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;28/02/1871&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f;"&gt;12/11/2007&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;01/01/1984&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f;"&gt;28/02/2005&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;29/02/2004&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Sample Output&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Case #1: Invalid birth date&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Case #2: Check birth date&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Case #3: 23&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Case #4: 0&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: magenta;"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class="Apple-style-span" style="color: #38761d; font-size: medium;"&gt;&lt;b&gt;Solution&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
using namespace std;

int main()
{
    int t,day,month,year,cDay,cMonth,cYear,i,age;
    while(scanf("%d",&amp;amp;t)==1)
    {
        for(i=1;i&amp;lt;=t;i++)
        {
            scanf("%d/%d/%d",&amp;amp;cDay,&amp;amp;cMonth,&amp;amp;cYear);
            scanf("%d/%d/%d",&amp;amp;day,&amp;amp;month,&amp;amp;year);
            if(cDay&amp;lt;day)
                month+=1;
            if(cMonth&amp;lt;month)
                year+=1;
            age=cYear-year;
            if(age&amp;lt;0)
                printf("Case #%d: Invalid birth date\n",i);
            else if(age&amp;gt;130)
                printf("Case #%d: Check birth date\n",i);
            else
                printf("Case #%d: %d\n",i,age);
        }
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/solution-of-11219-how-old-are-you.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-4382062541529683289</guid><pubDate>Sat, 09 Nov 2013 14:26:00 +0000</pubDate><atom:updated>2017-09-04T22:19:07.197+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volum 124</category><title>Solution of 12403 - Save Setu</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Problem Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source: https://uva.onlinejudge.org/external/124/p12403.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;Rahaduzzaman Setu, (Roll - 12) of 13th batch, CSE, University of Dhaka is tremendously ill. He has
been suffering from Multi Drug Resistant TB for a long time. Now, his left lung is damaged and
beyond repair. No medicine is working on his body to ease his pain. It is urgent to operate on his left
lung so that the disease doesn’t spread to his right lung. It can either be removed through surgery
or transplanted. He comes from a modest family and it is difficult and impossible for them to bare
his medical expenses anymore. Because of the money needed (12 million BDT) to transplant, it is his
family’s decision to go with the surgery (3 million BDT). We must help them financially by raising
money. But we must not be confined with that amount only to do the surgery. We must go for the
Transplant. Our target will be to collect as much as possible to help our friend.
If anyone wants to contribute now, please send me your contribution or contact me. Please contribute
as much as you can to save a life that you saw every week for the first two years of your University life.
Please contribute as per your abilities. Our combined effort may save a life.
For more information, consult the link below&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;https://supportsetu.com/&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;However, in this problem, you have to build a software that can calculate the donations. Initially
the total amount of money is 0 and in each time, two types of operations will be there.
1) ‘donate K’ (100 ≤ K ≤ 105
), then you have to add K to the account.
2) ‘report’, report all the money currently in the account.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;The first line of input will contain T (1 ≤ T ≤ 100) denoting the number of operations. Then there will
be T lines each containing two types of operations as given. You may assume that the input follows
the restrictions above.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;For each ‘report’ operation, print the total amount of money in the account.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;4&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;donate 1000&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;report&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;donate 500&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;report&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;Sample Output&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;1000&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;1500&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: magenta; font-size: medium;"&gt;&lt;b&gt;Solution&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;

using namespace std;
int main()
{
    long long int total,k,t,i;
    char str1[50];
    //freopen("in.txt","r",stdin);
    while(scanf("%lld",&amp;amp;t)==1)
    {
        total=0;
        for(i=1;i&amp;lt;=t;i++)
        {
            scanf("%s",&amp;amp;str1);
            if(strcmp(str1,"donate")==0)
            {
                scanf("%lld",&amp;amp;k);
                total+=k;
            }
            else
                printf("%lld\n",total);
        }
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/solution-of-12403-save-setu.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-428077757329016833</guid><pubDate>Sat, 09 Nov 2013 12:13:00 +0000</pubDate><atom:updated>2013-11-09T18:13:05.209+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ACM Algorithms</category><title>Algorithm of 11526 - H(n)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;a href="http://uva.onlinejudge.org/external/115/11526.html" target="_blank"&gt;&lt;span style="font-size: large;"&gt;Problem Description Link&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Algorithm&lt;/span&gt;&lt;br /&gt;
The problem is not difficult but we need to consider the problem of time limit exceeded, e.g. we are computing n/n, n/n-1, .....there are so many ones and twos,... these can be computed in one step. We can observe the number of 1, 2, 3.....the number of j is n/j - n/(j+1).&amp;nbsp; so when the number is small and many, we use the n/j - n/(j+1) method. for numbers big and few, just use the original method. We can set the break point at sqrt(n). Do not repeat the values around sqrt(n). Try to avoid division by 0 and sqrt of negative numbers.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;if n=5 series is 5/1 + 5/2 + 5/3 + 5/4 + 5/5&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; then sqrt(5)=2 need loop two times&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5/1-5/2=3 means 1 get 3 times, so SUM=3*1=3&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5/2-5/3=1 means 2 get 1 times, so SUM=3+2*1=5&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; so last 4 (3+1) steps complete from the series ,so now we nedd calculate first 1 step &lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5/1=5 , so SUM=5+5=10&lt;br /&gt;if n=10 series is 10/1 + 10/2 + 10/3 + 10/4 + 10/5+.... +10/10&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; then sqrt(10)=3 need loop two times&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/1-10/2=5 means 1 get 5 times, so SUM=5*1=5&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/2-10/3=2 means 2 get 2 times, so SUM=5+2*2=9&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/3-10/4=1 means 3 get 1 time, so SUM=9+3*1=12&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; so last 8(5+2+1) steps complete from the series ,so now we nedd calculate first 2 step &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/1=10 , so SUM=12+10=22&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/2=5 , so SUM=22+5=27&lt;br /&gt;&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/algorithm-of-11526-hn.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-8478354896241180641</guid><pubDate>Sat, 09 Nov 2013 12:05:00 +0000</pubDate><atom:updated>2017-09-05T19:54:07.305+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume CXV</category><title>Solution of 11526 - H(n)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Problem Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:&amp;nbsp;https://uva.onlinejudge.org/external/115/11526.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;What is the value this simple C++ function will return?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;long long H(int n){ 
    long long res = 0;
    for( int i = 1; i &amp;lt;= n; i=i+1 ){
        res = (res + n/i);
    } 
    return res; 
} 
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-size: medium;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;The first line of input is an integer T (T ≤ 1000) that indicates the number of test cases. Each of the
next T line will contain a single signed 32 bit integer n.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&amp;nbsp;For each test case, output will be a single line containing H(n).&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;2
5
10&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;10
27&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: magenta; font-size: medium;"&gt;&lt;b&gt;Solution&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;

using namespace std;

int main()
{
    long long int n,sum,i,j,k,rootn,loop1,loop2,t,noOfj;
    //freopen("input.txt","r",stdin);
    while(scanf("%lld",&amp;amp;t)==1)
    {
        for(k=1;k&amp;lt;=t;k++)
        {
            scanf("%lld",&amp;amp;n);
            loop1=0;
            loop2=0;
            sum=0;
            rootn=sqrt(n);
            for(j=1;j&amp;lt;=rootn;j++)
            {
                noOfj=(n/j)-(n/(j+1));
                loop1+=noOfj;
                sum+=noOfj*j;
            }
            loop2=n-loop1;
            for(i=1;i&amp;lt;=loop2;i++)
            {
                sum+=n/i;
            }
            printf("%lld\n",sum);
        }
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/solution-of-11526-hn.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-8343298345728636296</guid><pubDate>Tue, 05 Nov 2013 20:52:00 +0000</pubDate><atom:updated>2017-09-04T22:17:51.723+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume CV</category><title>Solution of 10523 - Very Easy !!!</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Problem Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:https://uva.onlinejudge.org/external/105/10523.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;Most of the times, the students of Computer Science &amp;amp; Engineering of BUET deal with bogus, tough and
very complex formulae. That is why, sometimes, even for a easy problem they think very hard and make
the problem much complex to solve. But, the team members of the team “BUET PESSIMISTIC”
are the only exceptions. Just like the opposite manner, they treat every hard problem as easy and so
cannot do well in any contest. Today, they try to solve a series but fail for treating it as hard. Let
them help.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;Just try to determine the answer for the following series
∑
N
i=1
iAi
You are given the value of integers N and A (1 ≤ N ≤ 150, 0 ≤ A ≤ 15).
&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Output&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;each line of the input, your correct program should output the integer value of the sum in separate
lines for each pair of values of N and A&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;3 3
4 4&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Output&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;102
1252&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="color: magenta;"&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;Solution&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;deque&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;list&amp;gt;
#include &amp;lt;map&amp;gt;
#include &amp;lt;queue&amp;gt;
#include &amp;lt;set&amp;gt;
#include &amp;lt;stack&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;

using namespace std;
void Multiply();
void MultiplyWithI(int value1);
void Addition();
int lena,lenb,lenResult,lenResult1,lenSum,result[1000],result1[1000],sum[1000],carry,temp,f;
char a[1000],b[1000],c[10];

int main()
{
    int n,i,j;
    //freopen("in.txt","r",stdin);
    while(scanf("%d%s",&amp;amp;n,&amp;amp;b)==2)
    {
        lenSum=0;
        lena=1;
        lenb=strlen(b);
        a[0]='1';
        for(j=1;j&amp;lt;=n;j++)
        {
            Multiply();
            lena=strlen(a);
            MultiplyWithI(j);
            Addition();
        }
        if(strcmp(b,"0")==0)
            printf("0");
        else
        {
            for(i=f;i&amp;gt;=1;i--)
            {
                printf("%d",sum[i]);
            }
        }

        printf("\n");
        memset(a,'\0',sizeof(a));
        memset(b,'\0',sizeof(b));
        memset(c,'\0',sizeof(c));
        memset(result,0,sizeof(result));
        memset(result1,0,sizeof(result1));
        memset(sum,0,sizeof(sum));
    }
    return 0;
}

void Multiply()
{

    int i,j,k,m=0,l;
    k=0;
        for(i=lenb-1;i&amp;gt;=0;i--)
        {
            k+=1;
            l=k-1;
            carry=0;
            for(j=lena-1;j&amp;gt;=0;j--)
            {
                l+=1;
                if(i==lenb-1)
                    temp=(b[i]-48)*(a[j]-48)+carry;
                else
                    temp=(b[i]-48)*(a[j]-48)+result[l]+carry;
                result[l]=temp%10;
                carry=temp/10;
            }
            if(carry&amp;gt;0)
            {
                l+=1;
                result[l]=carry;
            }
        }
        lenResult=l;
        for(i=l;i&amp;gt;=1;i--)
        {
            a[m++]=result[i]+48;
        }
}

void MultiplyWithI(int value1)
{
    int i,j,k,m=0,x=0,lenc,l;
    k=0;
    while(value1!=0)
    {
        c[x++]=(value1%10)+48;
        value1/=10;
    }
    lenc=strlen(c);
        for(i=0;i&amp;lt;=lenc-1;i++)
        {
            k+=1;
            l=k-1;
            carry=0;
            for(j=1;j&amp;lt;=lenResult;j++)
            {
                l+=1;
                if(i==0)
                    temp=(c[i]-48)*result[j]+carry;
                else
                    temp=(c[i]-48)*result[j]+result1[l]+carry;
                result1[l]=temp%10;
                carry=temp/10;
            }
            if(carry&amp;gt;0)
            {
                l+=1;
                result1[l]=carry;
            }
        }
        lenResult1=l;
}
void Addition()
{
    int i,max1,tem,k=0;
    max1=lenSum;
    if(lenResult1&amp;gt;lenSum)
        max1=lenResult1;
    carry=0;
    for(i=1;i&amp;lt;=max1;i++)
    {
     tem=sum[i]+result1[i]+carry;
     k+=1;
     sum[k]=tem%10;
     carry=tem/10;
    }
    if(carry&amp;gt;0)
    {
        k+=1;
        sum[k]=carry;
    }
    lenSum=k;
    f=k;
    memset(result1,0,sizeof(result1));
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/solution-of-10523-very-easy.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-4663237600332186093</guid><pubDate>Tue, 05 Nov 2013 20:36:00 +0000</pubDate><atom:updated>2017-09-04T22:16:40.438+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume CIII</category><title>Solution of 10324 - Zeros and Ones</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Problem Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source:https://uva.onlinejudge.org/external/103/10324.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;Given a string of 0’s and 1’s up to 1000000 characters long and indices i and j, you are to answer
a question whether all characters between position min(i, j) and position max(i, j) (inclusive) are the
same.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Input&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;There are multiple cases on input. The first line of each case gives a string of 0’s and 1’s. The next
line contains a positive integer n giving the number of queries for this case. The next n lines contain
queries, one per line. Each query is given by two non-negative integers, i and j. For each query, you
are to print ‘Yes’ if all characters in the string between position min(i, j) and position max(i, j) are the
same, and ‘No’ otherwise.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Output&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
Each case on output should start with a heading as in the sample below. The input ends with an empty
string that is a line containing only the new line character, this string should not be processed. The
input may also with end of file. So keep check for both.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Sample Input&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;0000011111&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;3&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;&amp;nbsp;0 5&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;4 2&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;5 9&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;01010101010101010101010101111111111111111111111111111111111110000000000000000&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;5&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;4 4&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;25 60&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;1 3 &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;62 76 &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;24 62&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;1&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;1&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;0 0&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Sample Output&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Case 1:&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;No&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Yes&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Yes&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Case 2:&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Yes&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Yes&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;No&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Yes&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;No&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Case 3:&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f;"&gt;Yes&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: magenta; font-size: medium;"&gt;&lt;b&gt;Solution&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;

using namespace std;
int main()
{
    register long int i,j,n,a,b,ma,mi,get,c=0;
    char input[1000005];
    //freopen("in.txt","r",stdin);
    while(scanf("%s",input)==1)
    {
        cin&amp;gt;&amp;gt;n;
        c+=1;
        printf("Case %ld:\n",c);
        for(i=1;i&amp;lt;=n;i++)
        {
            cin&amp;gt;&amp;gt;a&amp;gt;&amp;gt;b;
            ma=max(a,b);
            mi=min(a,b);
            get=0;
            for(j=mi+1;j&amp;lt;=ma;j++)
            {
                if(input[j]==input[j-1])
                {
                    continue;
                }
                else
                {
                    get=1;
                    break;
                }
            }
            if(get==1)
                printf("No\n");
            else
                printf("Yes\n");
        }
        memset(input,'\0',sizeof(input));
    }
    return 0;
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/solution-of-10324-zeros-and-ones.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-4722563828134088010</guid><pubDate>Mon, 04 Nov 2013 20:56:00 +0000</pubDate><atom:updated>2013-11-05T02:56:01.049+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ACM Algorithms</category><title>Algorithm of 10127 - Ones</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;a href="http://uva.onlinejudge.org/external/101/10127.html" target="_blank"&gt;&lt;span style="font-size: large;"&gt;Problem Description Link&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Algorithm&lt;/span&gt;&lt;br /&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:WordDocument&gt;
  &lt;w:View&gt;Normal&lt;/w:View&gt;
  &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
  &lt;w:TrackMoves/&gt;
  &lt;w:TrackFormatting/&gt;
  &lt;w:PunctuationKerning/&gt;
  &lt;w:ValidateAgainstSchemas/&gt;
  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
  &lt;w:DoNotPromoteQF/&gt;
  &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt;
  &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt;
  &lt;w:LidThemeComplexScript&gt;BN-BD&lt;/w:LidThemeComplexScript&gt;
  &lt;w:Compatibility&gt;
   &lt;w:BreakWrappedTables/&gt;
   &lt;w:SnapToGridInCell/&gt;
   &lt;w:WrapTextWithPunct/&gt;
   &lt;w:UseAsianBreakRules/&gt;
   &lt;w:DontGrowAutofit/&gt;
   &lt;w:SplitPgBreakAndParaMark/&gt;
   &lt;w:DontVertAlignCellWithSp/&gt;
   &lt;w:DontBreakConstrainedForcedTables/&gt;
   &lt;w:DontVertAlignInTxbx/&gt;
   &lt;w:Word11KerningPairs/&gt;
   &lt;w:CachedColBalance/&gt;
   &lt;w:UseFELayout/&gt;
  &lt;/w:Compatibility&gt;
  &lt;m:mathPr&gt;
   &lt;m:mathFont m:val="Cambria Math"/&gt;
   &lt;m:brkBin m:val="before"/&gt;
   &lt;m:brkBinSub m:val="--"/&gt;
   &lt;m:smallFrac m:val="off"/&gt;
   &lt;m:dispDef/&gt;
   &lt;m:lMargin m:val="0"/&gt;
   &lt;m:rMargin m:val="0"/&gt;
   &lt;m:defJc m:val="centerGroup"/&gt;
   &lt;m:wrapIndent m:val="1440"/&gt;
   &lt;m:intLim m:val="subSup"/&gt;
   &lt;m:naryLim m:val="undOvr"/&gt;
  &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;br /&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
  DefSemiHidden="true" DefQFormat="false" DefPriority="99"
  LatentStyleCount="267"&gt;
  &lt;w:LsdException Locked="false" Priority="0" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Normal"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 7"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 8"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 9"/&gt;
  &lt;w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/&gt;
  &lt;w:LsdException Locked="false" Priority="10" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Title"/&gt;
  &lt;w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/&gt;
  &lt;w:LsdException Locked="false" Priority="11" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/&gt;
  &lt;w:LsdException Locked="false" Priority="22" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Strong"/&gt;
  &lt;w:LsdException Locked="false" Priority="20" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="59" SemiHidden="false"
   UnhideWhenUsed="false" Name="Table Grid"/&gt;
  &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/&gt;
  &lt;w:LsdException Locked="false" Priority="1" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/&gt;
  &lt;w:LsdException Locked="false" Priority="34" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/&gt;
  &lt;w:LsdException Locked="false" Priority="29" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Quote"/&gt;
  &lt;w:LsdException Locked="false" Priority="30" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="19" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="21" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="31" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/&gt;
  &lt;w:LsdException Locked="false" Priority="32" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/&gt;
  &lt;w:LsdException Locked="false" Priority="33" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Book Title"/&gt;
  &lt;w:LsdException Locked="false" Priority="37" Name="Bibliography"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/&gt;
 &lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:"Table Normal";
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-qformat:yes;
 mso-style-parent:"";
 mso-padding-alt:0in 5.4pt 0in 5.4pt;
 mso-para-margin-top:0in;
 mso-para-margin-right:0in;
 mso-para-margin-bottom:10.0pt;
 mso-para-margin-left:0in;
 line-height:115%;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 mso-bidi-font-size:14.0pt;
 font-family:"Calibri","sans-serif";
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;}
&lt;/style&gt;
&lt;![endif]--&gt;

&lt;br /&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-left: 7.5pt; margin-right: 7.5pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;span style="font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;This is a very simple
but tricky problem. If you want to calculate the sequence of one by increasing
ONE, then two things can be happened.&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-left: 7.5pt; margin-right: 7.5pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;span style="font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;1) If your data type
is even long double (in C it is the highest data type), it can not hold the
sequence and because of overflow you will get WA.&lt;br /&gt;
2) If your data type is string then you will get "time limit
exceeded". To avoid these problems we need to follow a trick here.&lt;br /&gt;
&lt;br /&gt;
The Algorithm&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
input (it will be the input of the problem)&amp;nbsp; &lt;br /&gt;
dividend=1 &lt;br /&gt;
one=1 (in this variable finally we get how many one will be in the sequence) &lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;do {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;if&amp;nbsp;dividend &amp;lt; input&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;append a '1'.&amp;nbsp; (this the way -&amp;gt; dividend= dividend
*10+1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;one = one + 1 &lt;br /&gt;
&amp;nbsp;&amp;nbsp;k = dividend mod input&amp;nbsp; ( k is a variable )&lt;br /&gt;
&amp;nbsp; do this until k = 0, otherwise dividend = k and repeat everything&lt;br /&gt;
}&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;br /&gt;
&lt;b&gt;Example&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Let the input is 3 &lt;br /&gt;
At first dividend = 1 and one&amp;nbsp; = 1&lt;br /&gt;
&lt;br /&gt;
Now,&lt;br /&gt;
3 | 1 | but here dividend &amp;lt; input so, append a '1'&lt;br /&gt;
one = one + 1 = 2&lt;br /&gt;
3 | 11| 3&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;br /&gt;
&amp;nbsp;&amp;nbsp; -----&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; 2&lt;br /&gt;
Now, k = 2, so, dividend =k;&lt;br /&gt;
again,&lt;br /&gt;
&lt;br /&gt;
3 | 2 | but here dividend &amp;lt; input so append a '1'&lt;br /&gt;
one = one + 1 = 3&lt;br /&gt;
&lt;br /&gt;
3 | 21| 7&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 21&lt;br /&gt;
&amp;nbsp;&amp;nbsp;-----&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;br /&gt;
So the output is variable 'one' which contains the value 3&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;/span&gt;&lt;br /&gt;


&lt;div class="MsoNormal" style="line-height: normal; margin-left: 7.5pt; margin-right: 7.5pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;span style="font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Basically, this
problem is a reverse version of dividing a series of '1's with &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;dividend&lt;/span&gt;&lt;span style="font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;. In the example
above. The step by step of dividing "111" with "3" is like
this:&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-left: 7.5pt; margin-right: 7.5pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;3
|111| 37&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; =&amp;gt; the same '9' that we see above&lt;br /&gt;
&amp;nbsp; -----&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 21&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 21&amp;nbsp; =&amp;gt; the same '21' that we see above&lt;br /&gt;
&amp;nbsp;&amp;nbsp; ----&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal" style="line-height: normal; margin-left: 7.5pt; margin-right: 7.5pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"&gt;
&lt;span style="font-family: &amp;quot;Verdana&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;So, basically we just
simulate this division but without spanning out the actual string of '1's. &lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/algorithm-of-10127-ones.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-6990456065776605686</guid><pubDate>Fri, 01 Nov 2013 20:51:00 +0000</pubDate><atom:updated>2013-11-02T02:51:57.033+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ACM Algorithms</category><title>Algorithm of 713 - Adding Reversed Numbers</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;a href="http://uva.onlinejudge.org/external/7/713.html" target="_blank"&gt;&lt;span style="font-size: large;"&gt;Problem Description Link&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Algorithm&lt;/span&gt;&lt;br /&gt;
This is the simple string related problem. You can solve easily using your defined string adding function. you need first &lt;br /&gt;reverse the string that you entered and add two string. after adding print the result reveser order. You must &lt;br /&gt;&amp;nbsp;Omit any leading zeros in the output. &lt;br /&gt;You no need reverse the inputs if you adding atart from left most. but you nee create same length two string by insert 0.&lt;br /&gt;For Example:&lt;br /&gt;a=4358&lt;br /&gt;b=754&lt;br /&gt;length not same so create same length add 0 in b at right most&lt;br /&gt;b=7540&lt;br /&gt;&amp;nbsp;now add&lt;br /&gt;a=4358&lt;br /&gt;b=7540&lt;br /&gt;-----------&lt;br /&gt;r=1998 this is the result&lt;br /&gt;&lt;br /&gt;if a=305 and b= 794&lt;br /&gt;&lt;br /&gt;add&lt;br /&gt;&amp;nbsp;a=305&lt;br /&gt;&amp;nbsp;b=794&lt;br /&gt;---------------&lt;br /&gt;r= 0001 so you need avoid all leftmost 0 s, so 1 is the result.&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/algorithm-of-713-adding-reversed-numbers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1166892643301539141.post-9003022888055101821</guid><pubDate>Fri, 01 Nov 2013 20:47:00 +0000</pubDate><atom:updated>2017-09-04T22:15:34.923+06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Volume VII</category><title>Solution of 713 - Adding Reversed Numbers</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Problem Description&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: xx-small;"&gt;source: https://uva.onlinejudge.org/external/7/713.html&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;The Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancient
plays are tragedies. Therefore the dramatic advisor of ACM has decided to transfigure some tragedies
into comedies. Obviously, this work is very hard because the basic sense of the play must be kept intact,
although all the things change to their opposites. For example the numbers: if any number appears in
the tragedy, it must be converted to its reversed form before being accepted into the comedy play.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&amp;nbsp;Reversed number is a number written in arabic numerals but the order of digits is reversed. The
first digit becomes last and vice versa. For example, if the main hero had 1245 strawberries in the
tragedy, he has 5421 of them now. Note that all the leading zeros are omitted. That means if the
number ends with a zero, the zero is lost by reversing (e.g. 1200 gives 21). Also note that the reversed
number never has any trailing zeros.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;ACM needs to calculate with reversed numbers. Your task is to add two reversed numbers and
output their reversed sum. Of course, the result is not unique because any particular number is a
reversed form of several numbers (e.g. 21 could be 12, 120 or 1200 before reversing). Thus we must
assume that no zeros were lost by reversing (e.g. assume that the original number was 12).&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;The input consists of N cases. The first line of the input contains only positive integer N. Then follow
the cases. Each case consists of exactly one line with two positive integers separated by space. These
are the reversed numbers you are to add. Numbers will be at most 200 characters long.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Output&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;For each case, print exactly one line containing only one integer — the reversed sum of two reversed
numbers. Omit any leading zeros in the output.&lt;/span&gt;&lt;span style="font-size: large;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Input&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;3&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;24 1&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;4358 754&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;305 794&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: medium;"&gt;&lt;b&gt;Sample Output&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;&amp;nbsp;34&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;1998&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #6aa84f; font-size: medium;"&gt;1&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: magenta; font-size: medium;"&gt;&lt;b&gt;Solution&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush:cpp"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;cstring&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;

using namespace std;
void Addition(int length);
 char str1[250],str2[250],result[250];
 int len3;
 int main()
 {
     int i,j,len1,len2,t,k,difr;
     //freopen("in.txt","r",stdin);
     while(scanf("%d",&amp;amp;t)==1)
     {
         for(k=1;k&amp;lt;=t;k++)
         {
             scanf("%s %s",&amp;amp;str1,&amp;amp;str2);
             len3=0;
             len1=strlen(str1);
             len2=strlen(str2);
             if(len1&amp;gt;len2)
             {
                 difr=(len1-len2)+len2;
                 for(i=len2;i&amp;lt;difr;i++)
                    str2[i]='0';
                Addition(len1);
             }
             else
             {
                 difr=(len2-len1)+len1;
                 for(i=len1;i&amp;lt;difr;i++)
                    str1[i]='0';
                Addition(len2);
             }
             i=1;
             while(result[i]=='0')
             {
                 i++;
             }
             for(j=i;j&amp;lt;=len3;j++)
                printf("%c",result[j]);
             printf("\n");
             memset(str1,'\0',sizeof(str1));
             memset(str2,'\0',sizeof(str2));
             memset(result,'\0',sizeof(result));
         }
     }
     return 0;
 }
void Addition(int length)
{
    int i,tem,carry=0;
    len3=0;
    for(i=0;i&amp;lt;length;i++)
    {
     tem=(str1[i]-48)+(str2[i]-48)+carry;
     len3+=1;
     result[len3]=((tem%10)+48);
     carry=tem/10;
    }
    if(carry&amp;gt;0)
    {
        len3+=1;
        result[len3]=carry+48;
    }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://acmproblemsolution.blogspot.com/2013/11/solution-of-713-adding-reversed-numbers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Shaishab Roy)</author></item></channel></rss>