<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>usaco &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/usaco/</link>
	<description>Feed of posts on WordPress.com tagged "usaco"</description>
	<pubDate>Thu, 24 Dec 2009 02:57:29 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[TJU 2839.   Dream Counting ]]></title>
<link>http://itsevening.wordpress.com/2009/12/05/tju-2839-dream-counting/</link>
<pubDate>Sat, 05 Dec 2009 04:56:02 +0000</pubDate>
<dc:creator>whoami</dc:creator>
<guid>http://itsevening.wordpress.com/2009/12/05/tju-2839-dream-counting/</guid>
<description><![CDATA[TJU 2839. Dream Counting #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; i]]></description>
<content:encoded><![CDATA[TJU 2839. Dream Counting #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; i]]></content:encoded>
</item>
<item>
<title><![CDATA[TJU 2791.   Bovine Latin ]]></title>
<link>http://itsevening.wordpress.com/2009/11/19/tju-2791-bovine-latin/</link>
<pubDate>Thu, 19 Nov 2009 10:22:33 +0000</pubDate>
<dc:creator>whoami</dc:creator>
<guid>http://itsevening.wordpress.com/2009/11/19/tju-2791-bovine-latin/</guid>
<description><![CDATA[TJU 2791. Bovine Latin #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; int]]></description>
<content:encoded><![CDATA[TJU 2791. Bovine Latin #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; int]]></content:encoded>
</item>
<item>
<title><![CDATA[TJU 3205.   The Perfect Cow ]]></title>
<link>http://itsevening.wordpress.com/2009/11/18/tju-3205-the-perfect-cow/</link>
<pubDate>Wed, 18 Nov 2009 22:28:02 +0000</pubDate>
<dc:creator>whoami</dc:creator>
<guid>http://itsevening.wordpress.com/2009/11/18/tju-3205-the-perfect-cow/</guid>
<description><![CDATA[TJU 3205. The Perfect Cow --AC---- #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;stri]]></description>
<content:encoded><![CDATA[TJU 3205. The Perfect Cow --AC---- #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;stri]]></content:encoded>
</item>
<item>
<title><![CDATA[Prime Cryptarithm]]></title>
<link>http://tausiq.wordpress.com/2009/10/20/prime-cryptarithm/</link>
<pubDate>Tue, 20 Oct 2009 14:57:25 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/10/20/prime-cryptarithm/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: crypt1 LANG: C++ */ #include &lt;stdio.h&gt; int a [10]; int n; int count; boo]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: crypt1 LANG: C++ */ #include &lt;stdio.h&gt; int a [10]; int n; int count; boo]]></content:encoded>
</item>
<item>
<title><![CDATA[Calf Flac]]></title>
<link>http://tausiq.wordpress.com/2009/10/19/calf-flac/</link>
<pubDate>Sun, 18 Oct 2009 18:45:51 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/10/19/calf-flac/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: calfflac LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; #incl]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: calfflac LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; #incl]]></content:encoded>
</item>
<item>
<title><![CDATA[Barn Repair]]></title>
<link>http://tausiq.wordpress.com/2009/10/17/barn-repair/</link>
<pubDate>Sat, 17 Oct 2009 09:09:40 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/10/17/barn-repair/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: barn1 LANG: C++ */ #include &lt;cstdio&gt; #include &lt;algorithm&gt; using na]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: barn1 LANG: C++ */ #include &lt;cstdio&gt; #include &lt;algorithm&gt; using na]]></content:encoded>
</item>
<item>
<title><![CDATA[Mixing Milk]]></title>
<link>http://tausiq.wordpress.com/2009/10/11/mixing-milk/</link>
<pubDate>Sun, 11 Oct 2009 12:53:07 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/10/11/mixing-milk/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: milk LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;algorithm&gt; using na]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: milk LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;algorithm&gt; using na]]></content:encoded>
</item>
<item>
<title><![CDATA[Palindromic Squares]]></title>
<link>http://tausiq.wordpress.com/2009/10/10/palindromic-squares/</link>
<pubDate>Sat, 10 Oct 2009 01:26:14 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/10/10/palindromic-squares/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: palsquare LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; #inc]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: palsquare LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; #inc]]></content:encoded>
</item>
<item>
<title><![CDATA[Name That Number]]></title>
<link>http://tausiq.wordpress.com/2009/10/09/name-that-number/</link>
<pubDate>Fri, 09 Oct 2009 09:54:25 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/10/09/name-that-number/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: namenum LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; #inclu]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: namenum LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; #inclu]]></content:encoded>
</item>
<item>
<title><![CDATA[Transformations]]></title>
<link>http://tausiq.wordpress.com/2009/10/05/transformations/</link>
<pubDate>Mon, 05 Oct 2009 02:30:57 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/10/05/transformations/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: transform LANG: C++ */ #include &lt;stdio.h&gt; int n; char set1 [10] [12]; ch]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: transform LANG: C++ */ #include &lt;stdio.h&gt; int n; char set1 [10] [12]; ch]]></content:encoded>
</item>
<item>
<title><![CDATA[Your Ride Is Here]]></title>
<link>http://tausiq.wordpress.com/2009/09/29/your-ride-is-here/</link>
<pubDate>Tue, 29 Sep 2009 02:55:57 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/09/29/your-ride-is-here/</guid>
<description><![CDATA[/* ID: tausiq11 LANG: C TASK: ride */ #include &lt;stdio.h&gt; int main () { freopen (&quot;ride.in]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 LANG: C TASK: ride */ #include &lt;stdio.h&gt; int main () { freopen (&quot;ride.in]]></content:encoded>
</item>
<item>
<title><![CDATA[Broken Necklace]]></title>
<link>http://tausiq.wordpress.com/2009/09/29/broken-necklace/</link>
<pubDate>Tue, 29 Sep 2009 02:29:31 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/09/29/broken-necklace/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: beads LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;iostream&gt; #include]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: beads LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;iostream&gt; #include]]></content:encoded>
</item>
<item>
<title><![CDATA[Friday the Thirteenth]]></title>
<link>http://tausiq.wordpress.com/2009/09/29/friday-the-thirteenth/</link>
<pubDate>Tue, 29 Sep 2009 02:23:32 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/09/29/friday-the-thirteenth/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: friday LANG: C++ */ #include &lt;stdio.h&gt; int main () { freopen (&quot;frid]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: friday LANG: C++ */ #include &lt;stdio.h&gt; int main () { freopen (&quot;frid]]></content:encoded>
</item>
<item>
<title><![CDATA[Greedy Gift Givers]]></title>
<link>http://tausiq.wordpress.com/2009/09/29/greedy-gift-givers/</link>
<pubDate>Tue, 29 Sep 2009 02:19:37 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/09/29/greedy-gift-givers/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: gift1 LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; struct f]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: gift1 LANG: C++ */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; struct f]]></content:encoded>
</item>
<item>
<title><![CDATA[Dual Palindromes]]></title>
<link>http://tausiq.wordpress.com/2009/09/29/dual-palindromes/</link>
<pubDate>Tue, 29 Sep 2009 02:16:34 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/09/29/dual-palindromes/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: dualpal LANG: C++ */ #include &lt;iostream&gt; #include &lt;cstdlib&gt; #inclu]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: dualpal LANG: C++ */ #include &lt;iostream&gt; #include &lt;cstdlib&gt; #inclu]]></content:encoded>
</item>
<item>
<title><![CDATA[Milking Cows]]></title>
<link>http://tausiq.wordpress.com/2009/09/29/milking-cows/</link>
<pubDate>Tue, 29 Sep 2009 02:12:39 +0000</pubDate>
<dc:creator>Blog Admin</dc:creator>
<guid>http://tausiq.wordpress.com/2009/09/29/milking-cows/</guid>
<description><![CDATA[/* ID: tausiq11 PROG: milk2 LANG: C++ */ #include &lt;iostream&gt; using namespace std; int main () ]]></description>
<content:encoded><![CDATA[/* ID: tausiq11 PROG: milk2 LANG: C++ */ #include &lt;iostream&gt; using namespace std; int main () ]]></content:encoded>
</item>
<item>
<title><![CDATA[USACO-Broken Necklace]]></title>
<link>http://jiangyuebing.wordpress.com/2009/02/16/usaco-broken-necklace-2/</link>
<pubDate>Mon, 16 Feb 2009 07:53:13 +0000</pubDate>
<dc:creator>jiangyuebing</dc:creator>
<guid>http://jiangyuebing.wordpress.com/2009/02/16/usaco-broken-necklace-2/</guid>
<description><![CDATA[I will not include the problem in the blog anymore. Here is the solution for this program problem. T]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I will not include the problem in the blog anymore.</p>
<p>Here is the solution for this program problem. To simulate the circle, we can attach two necklace together to do the calculation. It is obvious we will double the time, but this make the result more intuitive to sense.</p>
<pre class="brush: cpp;">
/*
ID:yuebing1
LANG:C++
TASK:beads
 */
#include&lt;fstream&gt;
#include&lt;string&gt;
#include&lt;vector&gt;
using namespace std;
int main()
{
	ifstream fin(&quot;beads.in&quot;);
	ofstream fout(&quot;beads.out&quot;);
	/**/
	int iNum;
	fin&gt;&gt;iNum;
	string sNecklace,sLinkedNecklace;
	fin&gt;&gt;sNecklace;
	sLinkedNecklace=sNecklace+sNecklace;//&quot;+&quot; operation for string.
	int color(0); //color is used to track the color of last bead
	int current(0);//current is used to track
	//the number of beads on current segment
	int previous(0);// previous is used track
	//the number of beads on previous segment
	int result(0);
	int w(0);
	for(int i=0;(i&lt;iNum*2)&amp;&amp;(previous+current&lt;iNum);++i)
	{
		if (sLinkedNecklace[i]=='w')
			{
				w++;
				++current;
			}
		else if (sLinkedNecklace[i]==color)
			{
				w=0;
				++current;
			}
		else
		{
			color=sLinkedNecklace[i];
			if(previous+current&gt;result) result=previous+current;
			previous=current-w;
			current=1+w;
			w=0;
		}

	}
if(result&lt;(current+previous))
		{
			fout&lt;&lt;current+previous&lt;&lt;endl;
		}
	else
		{
		fout&lt;&lt;result&lt;&lt;endl;
		}
}
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[USACO-Friday the Thirteenth]]></title>
<link>http://jiangyuebing.wordpress.com/2009/02/15/usaco-friday-the-thirteenth/</link>
<pubDate>Sun, 15 Feb 2009 23:02:05 +0000</pubDate>
<dc:creator>jiangyuebing</dc:creator>
<guid>http://jiangyuebing.wordpress.com/2009/02/15/usaco-friday-the-thirteenth/</guid>
<description><![CDATA[Is Friday the 13th really an unusual event? That is, does the 13th of the month land on a Friday les]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Is Friday the 13th really an unusual event?</p>
<p>That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January 1, 1900 to December 31, 1900+N-1 for a given number of years, N. N is non-negative and will not exceed 400.</p>
<p>There are few facts you need to know before you can solve this problem:</p>
<p>* January 1, 1900 was on a Monday.<br />
* Thirty days has September, April, June, and November, all the rest have 31 except for February which has 28 except in leap years when it has 29.<br />
* Every year evenly divisible by 4 is a leap year (1992 = 4*498 so 1992 will be a leap year, but the year 1990 is not a leap year)<br />
* The rule above does not hold for century years. Century years divisible by 400 are leap years, all other are not. Thus, the century years 1700, 1800, 1900 and 2100 are not leap years, but 2000 is a leap year.</p>
<p>Do not use any built-in date functions in your computer language.</p>
<p>Don&#8217;t just precompute the answers, either, please.<br />
<strong>my experience</strong><br />
the return value should be &#8220;return 0&#8243;</p>
<pre style="text-align:left;">
<pre class="brush: cpp;">
 /*
ID:yuebing1
 PROG:friday
 LANG:C++
 */
#include&lt;fstream&gt;
#include&lt;vector&gt;
using namespace std;
int main()
{	int iN;
		ifstream fin(&quot;friday.in&quot;);
		ofstream fout(&quot;friday.out&quot;);

		long day(13);	//bias for Monday,1900:1:1.
		int day_name(0);
		vector&lt;int&gt; statistics(7,0);
		int month[12]={31,0,31,30,31,30,31,31,30,31,30,31};
	fin&gt;&gt;iN;
	int limit=1900+iN;
	for(int i=1900; i
	&lt;limit; i++)
	{
		if ((i%4==0)&amp;&amp;(i%100!=0)&amp;#124;&amp;#124;(i%400==0))//leap year
		{
			month[1]=29;
		}
		else	//normal year
		{
			month[1]=28;
		}

			for(int j=0;j&lt;12;j++)
			{
			day_name=(day)%7;
			statistics[day_name]+=1;
			day+=month[j];
			}
	}
fout&lt;&lt;statistics[6];
	for(int i=0;i&lt;=5;i++)
			fout&lt;&lt;' '&lt;&lt;statistics[i];
			fout&lt;&lt;endl;
	return 0;
}
</pre>
<p>There is another way of figuring out the date's name actually , in the following program you can see how it works.</p>
<pre class="brush: cpp;">
/*
ID:yuebing1
PROB:friday
LANG:C++
 */
#include&lt;iostream&gt;
#include&lt;fstream&gt;
using namespace std;

int to(int x,int m,int d)
{
		if(m&lt;3){m+=12;x--;}
		int c=(x/100);
		int y=x-100*c;
		int w=((c/4)-(2*c)+y+(y/4)+(26*(m + 1)/10)+d-1)%7;
		return (w+7)%7;
}

int main()
{
int n;
ifstream fin(&quot;friday.in&quot;);
ofstream fout(&quot;friday.out&quot;);
fin&gt;&gt;n;
	int x[7]={0};
for(int i=1900;i&lt;1900+n;i++)
{
	for(int j=1;j&lt;=12;j++)
	{
	x[to(i,j,13)]++;
	}
}

fout&lt;&lt;x[6];
for(int i=0;i&lt;=5;i++)
	{
	fout &lt;&lt;&quot; &quot;&lt;&lt;x[i];
	}
	fout &lt;&lt;endl;
	return 0;
}
</pre>
<p>By comparing the difference between other's code and mine, I find that mine is not quite standard but more concise.</p>
<pre class="brush: cpp;">
/*
ID: lixianm1
PROG: friday
LANG: C++
*/
#include
#include
#include
#include
#include
#include 

inline bool IsLeapYear(unsigned int nYear) {return ((!(nYear&amp;#38;3))&amp;#38;&amp;#38;(0!=nYear%100))&amp;#124;&amp;#124;(0==nYear%400);}

int main(int argc, char* argv[])
{
    //////////////////////////////////////////////////////////////////////////open the file
    std::string strInFile    = &quot;friday.in&quot;;
    std::string strOutFile    = &quot;friday.out&quot;;

    std::ifstream fin(strInFile.c_str());
    std::ofstream fout(strOutFile.c_str());

    if (!fin)
    {
        std::cout&amp;#60;&amp;#60;&quot;failed to open file for read&quot;&amp;#60;&amp;#60;std::endl;
        return 1;
    }
    if (!fout)
    {
        std::cout&amp;#60;&amp;#60;&quot;failed to open file for write&quot;&amp;#60;&amp;#62;N;

    //////////////////////////////////////////////////////////////////////////process

    static int month_day[]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    static int month_day2[]={0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    int aWeekCount[7]={0};
    unsigned int nTotalDays= 0;

    for (int i=0; i&amp;#60;N; ++i)
    {
        for (int nMonth=1; nMonth&amp;#60;13; ++nMonth)
        {
            ++aWeekCount[(nTotalDays+12)%7];

            if (!IsLeapYear(1900+i))
            {
                nTotalDays+=month_day[nMonth];
            }else
            {
                nTotalDays+=month_day2[nMonth];
            }
        }
    }

    //////////////////////////////////////////////////////////////////////////write the process result
    for (int i=0; i&amp;#60;6; ++i)
    {
        fout&amp;#60;&amp;#60;aWeekCount[(i+5)%7]&amp;#60;&amp;#60;&quot; &quot;;
    }
    fout&amp;#60;&amp;#60;aWeekCount[4]&amp;#60;&amp;#60;std::endl;

    //////////////////////////////////////////////////////////////////////////end and exit
    fin.close();
    fout.close();

    //system(&quot;pause&quot;);
    return 0;
}
</pre>
<p>At the end is the program from analysis which is written in c:</p>
<pre class="brush: cpp;">
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;assert.h&gt;

int
isleap(int y)
{
    return y%4==0 &amp;&amp; (y%100 != 0 &amp;#124;&amp;#124; y%400 == 0);
}

int mtab[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

/* return length of month m in year y */
int
mlen(int y, int m)
{
    if(m == 1)    /* february */
        return mtab[m]+isleap(y);
    else
        return mtab[m];
}

void
main(void)
{
    FILE *fin, *fout;
    int i, m, dow, n, y;
    int ndow[7];

    fin = fopen(&quot;friday.in&quot;, &quot;r&quot;);
    fout = fopen(&quot;friday.out&quot;, &quot;w&quot;);
    assert(fin != NULL &amp;&amp; fout != NULL);

    fscanf(fin, &quot;%d&quot;, &amp;n);

    for(i=0; i&lt;7; i++)
        ndow[i] = 0;

    dow = 0;    /* day of week: January 13, 1900 was a Saturday = 0 */
    for(y=1900; y&lt;1900+n; y++) {
        for(m=0; m&lt;12; m++) {
            ndow[dow]++;
            dow = (dow+mlen(y, m)) % 7;
        }
    }

    for(i=0; i&lt;7; i++) {
        if(i)
            fprintf(fout, &quot; &quot;);
        fprintf(fout, &quot;%d&quot;, ndow[i]);
    }
    fprintf(fout, &quot;\n&quot;);

    exit(0);
}
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[USACO Greedy-Gift-Giver]]></title>
<link>http://jiangyuebing.wordpress.com/2009/02/13/usaco-greedy-gift-giver/</link>
<pubDate>Fri, 13 Feb 2009 20:44:26 +0000</pubDate>
<dc:creator>jiangyuebing</dc:creator>
<guid>http://jiangyuebing.wordpress.com/2009/02/13/usaco-greedy-gift-giver/</guid>
<description><![CDATA[A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of t]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p> A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receive money from any or all of the other friends. Your goal in this problem is to deduce how much more money each person gives than they receive.</p>
<p>The rules for gift-giving are potentially different than you might expect. Each person sets aside a certain amount of money to give and divides this money evenly among all those to whom he or she is giving a gift. No fractional money is available, so dividing 3 among 2 friends would be 1 each for the friends with 1 left over &#8212; that 1 left over stays in the giver&#8217;s &#8220;account&#8221;.</p>
<p>In any group of friends, some people are more giving than others (or at least may have more acquaintances) and some people have more money than others.</p>
<p>Given a group of friends, no one of whom has a name longer than 14 characters, the money each person in the group spends on gifts, and a (sub)list of friends to whom each person gives gifts, determine how much more (or less) each person in the group gives than they receive.</p>
<pre class="brush: cpp;">
/*
ID:yuebing1
PROG:gift1
LANG:C++
*/
#include &lt;fstream&gt;
#include &lt;map&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &lt;queue&gt;
using namespace std;
int main()
{
	ifstream fin(&quot;gift1.in&quot;);
	ofstream fout(&quot;gift1.out&quot;);
	int iTotal;
	string name;
	map &lt;string, int&gt; people;
	int money,divide;
	map &lt;string,int&gt;::iterator person;
	queue &lt;string&gt; record;
	fin&gt;&gt;iTotal;

	for (int i=0;i&lt;iTotal;i++)
	{
			fin&gt;&gt;name;
			people.insert(make_pair(name,0));
			record.push(name);
	}
	for(int i=0;i&lt;iTotal;i++)
	{
		fin&gt;&gt;name;
		person=people.find(name);
		fin&gt;&gt;money&gt;&gt;divide;
	if(divide&gt;0)
		person-&gt;second-=(money/divide)*divide;

		for(int j=0;j&lt;divide;j++)
		{
			fin&gt;&gt;name;
			person=people.find(name);
			person-&gt;second+=money/divide;

		}

	}

	for(int i=0;i&lt;iTotal;i++)
		{
			name=record.front();
			record.pop();
			person=people.find(name);
			fout&lt;&lt;name&lt;&lt;' '&lt;&lt;person-&gt;second&lt;&lt;endl;
		}
}
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[USACO February Contest - Gold Division]]></title>
<link>http://purplelight.wordpress.com/2009/02/11/usaco-february-contest-gold-division/</link>
<pubDate>Wed, 11 Feb 2009 05:43:15 +0000</pubDate>
<dc:creator>whatevalah</dc:creator>
<guid>http://purplelight.wordpress.com/2009/02/11/usaco-february-contest-gold-division/</guid>
<description><![CDATA[yeehaa&#8230; akhirnya setelah kontes pertama divisi Gold gue bulan lalu hancur lebur dengan hanya 1]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>yeehaa&#8230; akhirnya setelah kontes pertama divisi Gold gue bulan lalu hancur lebur dengan hanya 162 poin (algo ngaco, salah baca soal, alhasil ngais2 nilai sekitar 1-3 test case per soal -_-&#8221;), untuk bulan ini ada sedikit kemajuan <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />   Full score di 1 soal (prob: revamp), dan 1 soal lagi (shuttle) kena WA karena rekurens gue emang salah!! Jadinya cuma dapet beberapa case&#8230; Trus 1 lagi soal ga gue kerjain, itu soal paling keren lupa judulnya, yang jelas main2 saham punya, <!--more-->agak mirip knapsack tapi bingung gmn&#8230; wkwkwkwkwk&#8230;..</p>
<p>- Yang &#8220;revamp&#8221; gue pake a* tapi tanpa heuristik, cuma di bound dengan state-state. Awalnya sempet takut kena TLE, tapi setelah itung2 keknya pas&#8230; jadi hajar dah&#8230; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
- Yang shuttle cuma dapat yang DP o(nc), tapi ngaco banget&#8230; hahaha&#8230;.</p>
<p>Here is the result :</p>
<p>- &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - ss_imposs1 &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - -<br />
- &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - USACO FEB09 &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - &#8211; </p>
<p>             Eko Mirhard  / IDN / Grad: 2007 / Div: Gold<br />
As an observer, YOUR RESULTS MIGHT NOT APPEAR ON THE FINAL WEB LISTINGS</p>
<p>Below are the results of grading your submissions against the test data for<br />
the contest.</p>
<p>============================== SUMMARY =============================</p>
<p>                            &#8212; case number &#8211;<br />
            1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17<br />
revamp      *  *  *  *  *  *  *  *  *  *  *<br />
shuttle     *  *  *  x  x  x  x  x  x  x  x  x  x  x  x  x  x</p>
<p>. = no entry   t = time exceeded    *   = correct answer<br />
x = wrong      s = signal           e   = bad exit status</p>
<p>Overall soal-soalnya sperti biasa keren2 dan cukup fresh&#8230; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
Bagi yang mau baca soal, ke <a href="http://contest.usaco.org/">sini</a> aja, kalo mau unduh test case atau baca pembahasan, bisa ke <a href="http://ace.delos.com/FEB09">sini</a></p>
<p>C u then&#8230; ^^</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
