<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EragonJ - A humble navigator &#187; ACM</title>
	<atom:link href="http://eragonj.hax4.in/blog/category/acm/feed" rel="self" type="application/rss+xml" />
	<link>http://eragonj.hax4.in/blog</link>
	<description></description>
	<lastBuildDate>Thu, 05 Jan 2012 12:33:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>[ACM] List of solved problems</title>
		<link>http://eragonj.hax4.in/blog/acm-list-of-solved-problems.html</link>
		<comments>http://eragonj.hax4.in/blog/acm-list-of-solved-problems.html#comments</comments>
		<pubDate>Sat, 05 Mar 2011 05:11:19 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>
		<category><![CDATA[PKU]]></category>
		<category><![CDATA[UVa]]></category>
		<category><![CDATA[ZeroJudge]]></category>
		<category><![CDATA[程式競技]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=909</guid>
		<description><![CDATA[Tweet Image Credit 最後一個學期，有幸上到 Electron 電子哥第一次也是最後一次開的「程式競技」，總算是有一個目標來推動自己去寫這些題目（雖然在成功高中的時候就和電研社的朋友們寫了一些了，好懷念呀），所以想要做個統一整理，把所有解過的問題都放到 Github Repo 上面並附加註解，做個記錄。 這篇會一直持續更新，如果有興趣的人可以觀注這篇文章。 Uva 944 &#8211; Happy Number 10055 &#8211; Hashmat the Brave Warrior 10300 &#8211; Ecological Premium 10302 &#8211; Summation of Polynomials 10323 &#8211; Factorial! You Must be Kidding!!! 10327 &#8211; Flip Sort 10346 &#8211; Peter&#8217;s Smokes 10420 &#8211; List of Conquests 10499 &#8211; The Land of [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2Facm-list-of-solved-problems.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/acm-list-of-solved-problems.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/acm-list-of-solved-problems.html"  data-text="[ACM] List of solved problems" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p style="text-align:right;"><a href="http://www.taekwondo-vs.ro/images/taekwondo.jpg">Image Credit</a></p>
<p style="text-align:center;">
<a href="http://eragonj.hax4.in/blog/wp-content/uploads/2011/03/taekwondo.jpeg"><img src="http://eragonj.hax4.in/blog/wp-content/uploads/2011/03/taekwondo.jpeg" alt="" title="taekwondo" width="369" height="350" class="size-full wp-image-914" /></a>
</p>
<p>最後一個學期，有幸上到 Electron 電子哥第一次也是最後一次開的「程式競技」，總算是有一個目標來推動自己去寫這些題目（雖然在成功高中的時候就和電研社的朋友們寫了一些了，好懷念呀），所以想要做個統一整理，把所有解過的問題都放到 Github Repo 上面並附加註解，做個記錄。</p>
<p>這篇會一直持續更新，如果有興趣的人可以觀注這篇文章。</p>
<h1><a href="http://uva.onlinejudge.org/">Uva</a></h1>
<ul>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/944/944.cpp">944     &#8211; Happy Number</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10055/10055.cpp">10055 &#8211; Hashmat the Brave Warrior</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10300/10300.cpp">10300 &#8211; Ecological Premium</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10302/10302.cpp">10302 &#8211; Summation of Polynomials</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10323/10323.cpp">10323 &#8211; Factorial! You Must be Kidding!!!</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10327/10327.cpp">10327 &#8211; Flip Sort</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10346/10346.cpp">10346 &#8211; Peter&#8217;s Smokes</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10420/10420.cpp">10420 &#8211; List of Conquests</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10499/10499.cpp">10499 &#8211; The Land of Justice</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10696/10696.cpp">10696 &#8211; f91</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/10810/10810.cpp">10810 &#8211; Ultra-QuickSort</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/uva/11727/11727.cpp">11727 &#8211; Cost Cutting</a></li>
</ul>
<h1><a href="http://140.122.185.166/ZeroJudge/">ZeroJudgeー大專院校版</a></h1>
<ul>
<li><a href="https://github.com/EragonJ/ACM/blob/master/zj/a100/a100.cpp">a100 &#8211; Sample Assignment</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/zj/d021/d021.cpp">d021 &#8211; E &#8211; To and Fro</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/zj/d040/d040.cpp">d040 &#8211; D &#8211; Document Shuffler</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/zj/d070/d070.cpp">d070 &#8211; A &#8211; Funny Decoder</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/zj/p001/p001.cpp">p001 &#8211; Minesweeper</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/zj/p006/p006.cpp">p006 &#8211; Jolly Jumpers</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/zj/p009/p009.cpp">p009 &#8211; WERTYU</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/zj/p017/p017.cpp">p017 &#8211; Ones</a></li>
</ul>
<h1><a href="http://poj.org/">PKU online Judge</a></h1>
<ul>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/1000/1000.cpp">1000 &#8211; A+B problem</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/1002/1002.cpp">1002 &#8211; 487-3279</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/1007/1007.cpp">1007 &#8211; DNA Sorting</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/1207/1207.cpp">1207 &#8211; The 3n+1 problem</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/1250/1250.cpp">1250 &#8211; Tanning Salon</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/1318/1318.cpp">1318 &#8211; Word Amalgamation</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/2231/2231.cpp">2231 &#8211; Moo Volume</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/2371/2371.cpp">2371 &#8211; Questions and answers</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/2388/2388.cpp">2388 &#8211; Who&#8217;s in the Middle</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/3663/3663.cpp">3663 &#8211; Costume Party</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/3664/3664.cpp">3664 &#8211; Election Time</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/3671/3671.cpp">3671 &#8211; Dining Cows</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/3672/3672.cpp">3672 &#8211; Long Distance Racing</a></li>
<li><a href="https://github.com/EragonJ/ACM/blob/master/poj/3673/3673.cpp">3673 &#8211; Cow Multiplication</a></li>
</ul>
<p><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/acm-list-of-solved-problems.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[ZeroJudge] p001 Minesweeper</title>
		<link>http://eragonj.hax4.in/blog/zerojudge-p001-minesweeper.html</link>
		<comments>http://eragonj.hax4.in/blog/zerojudge-p001-minesweeper.html#comments</comments>
		<pubDate>Tue, 02 Feb 2010 06:37:42 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[Hax4]]></category>
		<category><![CDATA[Minesweeper]]></category>
		<category><![CDATA[p001]]></category>
		<category><![CDATA[ZeroJudge]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=157</guid>
		<description><![CDATA[Tweet 最近又開始覺得很無聊，所以要回去寫題目來練習，剛好就拿ZJ2的Minesweeper來小試一下， 點我看題目 這個題目就是要實作簡單版的採地雷(概念上)，所以還蠻有趣的XD。 P.S. 我發現我之前寫ACM的文章都是用code tag包起來，但是只要沒有相對應的Css來搭配就真的是什麼都顯示不出來，有夠給他難看的&#8230;我晚點再來把他們都放上gist!]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2Fzerojudge-p001-minesweeper.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/zerojudge-p001-minesweeper.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/zerojudge-p001-minesweeper.html"  data-text="[ZeroJudge] p001 Minesweeper" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>最近又開始覺得很無聊，所以要回去寫題目來練習，剛好就拿ZJ2的Minesweeper來小試一下，</p>
<p><a href="http://140.122.185.166/ZeroJudge/ShowProblem?problemid=p001">點我看題目</a></p>
<p>這個題目就是要實作簡單版的採地雷(概念上)，所以還蠻有趣的XD。</p>
<p>P.S.  我發現我之前寫ACM的文章都是用code tag包起來，但是只要沒有相對應的Css來搭配就真的是什麼都顯示不出來，有夠給他難看的&#8230;我晚點再來把他們都放上gist!</p>
<p><script src="http://gist.github.com/292438.js?file=gistfile1.hpp"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/zerojudge-p001-minesweeper.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PKU]1503 Integer_Inquiry</title>
		<link>http://eragonj.hax4.in/blog/pku1503-integer_inquiry.html</link>
		<comments>http://eragonj.hax4.in/blog/pku1503-integer_inquiry.html#comments</comments>
		<pubDate>Fri, 11 Dec 2009 05:05:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>
		<category><![CDATA[1503]]></category>
		<category><![CDATA[Integer_Inquiry]]></category>
		<category><![CDATA[PKU]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=39</guid>
		<description><![CDATA[Tweet 我寫到快殺人了&#8230; 其實這題我一直都寫好了，但是就一直WA，最該死的就是我不知道問題在哪&#8230;也看了很多討論，但是就不知道錯在哪，有心的幫幫我一下吧.. PKU的測試位置(要帳號)]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2Fpku1503-integer_inquiry.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/pku1503-integer_inquiry.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/pku1503-integer_inquiry.html"  data-text="[PKU]1503 Integer_Inquiry" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>我寫到快殺人了&#8230;</p>
<p>其實這題我一直都寫好了，但是就一直WA，最該死的就是我不知道問題在哪&#8230;也看了很多討論，但是就不知道錯在哪，有心的幫幫我一下吧..</p>
<p><script src="http://gist.github.com/254197.js"></script><br /><a href="http://acm.pku.edu.cn/JudgeOnline/problem?id=1503">PKU的測試位置(要帳號)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/pku1503-integer_inquiry.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[ZeroJudge]p018 Polynomial coefficients</title>
		<link>http://eragonj.hax4.in/blog/zerojudgep018-polynomial-coefficients.html</link>
		<comments>http://eragonj.hax4.in/blog/zerojudgep018-polynomial-coefficients.html#comments</comments>
		<pubDate>Fri, 04 Dec 2009 10:52:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>
		<category><![CDATA[ZeroJudge]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=36</guid>
		<description><![CDATA[Tweet 就是多項式係數計算的簡化版，因為X1 , X2 &#8230;. Xn 就只是個變數，不會有像高中數學那樣，還要考慮因為次方而多產生的係數，算是蠻簡單的，只是這邊用到Recursive的Factorial計算，他有故意限定是 (0＜K,N＜13)，所以用long long int 去算就可以了，沒有太多困難。]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2Fzerojudgep018-polynomial-coefficients.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/zerojudgep018-polynomial-coefficients.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/zerojudgep018-polynomial-coefficients.html"  data-text="[ZeroJudge]p018 Polynomial coefficients" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>就是多項式係數計算的簡化版，因為X1 , X2 &#8230;. Xn 就只是個變數，不會有像<br />高中數學那樣，還要考慮因為次方而多產生的係數，算是蠻簡單的，只是這邊<br />用到Recursive的Factorial計算，他有故意限定是 (0＜K,N＜13)，所以用<br />long long int 去算就可以了，沒有太多困難。</p>
<p><script src="http://gist.github.com/249248.js?file=gistfile1.h"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/zerojudgep018-polynomial-coefficients.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[UVa]944 Happy Numbers</title>
		<link>http://eragonj.hax4.in/blog/uva944-happy-numbers.html</link>
		<comments>http://eragonj.hax4.in/blog/uva944-happy-numbers.html#comments</comments>
		<pubDate>Fri, 27 Nov 2009 10:15:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>
		<category><![CDATA[happy numbers]]></category>
		<category><![CDATA[UVa]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=35</guid>
		<description><![CDATA[Tweet 要注意一下題目的換行是要在兩個output之間 , 最後一個output就不能送出 endline ..]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2Fuva944-happy-numbers.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/uva944-happy-numbers.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/uva944-happy-numbers.html"  data-text="[UVa]944 Happy Numbers" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>要注意一下題目的換行是要在兩個output之間 , 最後一個output就不能送出 endline ..<br /><script src="http://gist.github.com/242673.js?file=gistfile1.h"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/uva944-happy-numbers.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[ACM] 3n+1</title>
		<link>http://eragonj.hax4.in/blog/acm-3n1.html</link>
		<comments>http://eragonj.hax4.in/blog/acm-3n1.html#comments</comments>
		<pubDate>Mon, 23 Mar 2009 18:36:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>
		<category><![CDATA[3n+1]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=23</guid>
		<description><![CDATA[Tweet 太久沒有寫code了 , 想說來寫寫練習一下 , 剛好看到有人的3n+1的code , 想說來寫個比較簡短的版本 , 直接recursive 下去做真的是方便時很多呢! BTW , 我發現我真的很愛用三元運算子= =&#8221; , 清楚又短~ #include &#60;stdio.h&#62; void cal(int,int);int m_cal(int,int);int main (int argc, const char * argv[]) { int input1,input2; while(scanf(&#34;%d%d&#34;,&#38;input1,&#38;input2)!=-1){ cal(input1,input2); } return 0;}int m_cal(int a,int length){ if(a==1){ return length; }else if(a%2==1){ return m_cal(a*3+1,length+1); }else{ return m_cal(a/2,length+1); }}void cal(int a,int b){ int [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2Facm-3n1.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/acm-3n1.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/acm-3n1.html"  data-text="[ACM] 3n+1" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>太久沒有寫code了 , 想說來寫寫練習一下 , 剛好看到有人的3n+1的code , 想說來寫個比較簡短的版本 , 直接recursive 下去做真的是方便時很多呢!</p>
<p>BTW , 我發現我真的很愛用三元運算子= =&#8221; , 清楚又短~</p>
<p><code><br />#include &lt;stdio.h&gt; <br />void cal(int,int);<br />int m_cal(int,int);<br />int main (int argc, const char * argv[]) {<br /> int input1,input2;<br /> while(scanf(&quot;%d%d&quot;,&amp;input1,&amp;input2)!=-1){<br />  cal(input1,input2);<br /> }<br /> return 0;<br />}<br />int m_cal(int a,int length){<br /> if(a==1){<br />  return length;<br /> }else if(a%2==1){<br />  return m_cal(a*3+1,length+1);<br /> }else{<br />  return m_cal(a/2,length+1);<br /> }<br />}<br />void cal(int a,int b){<br /> int i=a&gt;b?b:a,j=a&gt;b?a:b;<br /> int temp,memory=0;<br /> for(i;i&lt;=j;i++){<br />  temp = m_cal(i,1);<br />  memory = temp&gt;memory ? temp:memory;<br /> }<br /> printf(&quot;%d %d %dn&quot;,a,b,memory);<br />}<br /></code></p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/acm-3n1.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[ZeroJudge] a010 因數分解</title>
		<link>http://eragonj.hax4.in/blog/zerojudge-a010-%e5%9b%a0%e6%95%b8%e5%88%86%e8%a7%a3.html</link>
		<comments>http://eragonj.hax4.in/blog/zerojudge-a010-%e5%9b%a0%e6%95%b8%e5%88%86%e8%a7%a3.html#comments</comments>
		<pubDate>Thu, 22 Jan 2009 02:24:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>
		<category><![CDATA[a010]]></category>
		<category><![CDATA[ZeroJudge]]></category>
		<category><![CDATA[因數分解]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=13</guid>
		<description><![CDATA[Tweet 這題也是有點有趣 , 不過我自己的做法比較笨一點 ,就是先開個可以容的下題目的array[1000000] , 然後去存哪些因數有算過就++ , 最後再去總結算 ! 要注意的地方:1.我用了recursive的方法去實做2.用search function 去找有x個格子的數字不是0 (x-1就是乘號的數目) 大概就是這樣! 如果有什麼比較好的方法請提供一下:D #include &#60;iostream&#62;#define MAX 1000000using namespace std;int arr[MAX]={0};void div(int input){ int i; int sinput = input; for(i=2;i&#60;=sinput;i++){ if(sinput%i==0){ arr[i]+=1; sinput/=i; break; } } if(input!=sinput){ div(sinput); return ; }}void reset(){ int i; for(i=0;i&#60;MAX;i++){ arr[i]=0; }}int search(){ int i,count=0; for(i=2;i&#60;MAX;i++){ if(arr[i]!=0) count++; [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2Fzerojudge-a010-%25e5%259b%25a0%25e6%2595%25b8%25e5%2588%2586%25e8%25a7%25a3.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/zerojudge-a010-%e5%9b%a0%e6%95%b8%e5%88%86%e8%a7%a3.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/zerojudge-a010-%e5%9b%a0%e6%95%b8%e5%88%86%e8%a7%a3.html"  data-text="[ZeroJudge] a010 因數分解" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>這題也是有點有趣 , 不過我自己的做法比較笨一點 ,<br />就是先開個可以容的下題目的array[1000000] , 然後<br />去存哪些因數有算過就++ , 最後再去總結算 !</p>
<p>要注意的地方:<br />1.我用了recursive的方法去實做<br />2.用search function 去找有x個格子的數字不是0 (x-1就是乘號的數目)</p>
<p>大概就是這樣! 如果有什麼比較好的方法請提供一下:D</p>
<p><code><br />#include &lt;iostream&gt;<br />#define MAX 1000000<br />using namespace std;<br />int arr[MAX]={0};<br />void div(int input){<br />    int i;<br />    int sinput = input;<br />    for(i=2;i&lt;=sinput;i++){<br />        if(sinput%i==0){<br />            arr[i]+=1;<br />            sinput/=i;<br />            break;    <br />        }<br />    }<br />    if(input!=sinput){<br />        div(sinput);<br />        return ;    <br />    }<br />}<br />void reset(){<br />    int i;<br />    for(i=0;i&lt;MAX;i++){<br />        arr[i]=0;    <br />    }<br />}<br />int search(){<br />    int i,count=0;<br />    for(i=2;i&lt;MAX;i++){<br />        if(arr[i]!=0) count++;<br />    }    <br />    return count;<br />}<br />int main(){</p>
<p>    int h,i,k,scount=0;</p>
<p>    while(cin &gt;&gt; i){<br />        div(i);<br />        scount = search()-1;<br />        for(k=2;k&lt;MAX;k++){<br />            if(arr[k]!=0){<br />                if(arr[k]==1){<br />                    cout &lt;&lt; k ;<br />                }else{<br />                    cout &lt;&lt; k &lt;&lt; "^" &lt;&lt; arr[k] ;   <br />                }<br />                if(scount!=0){<br />                    cout &lt;&lt; " * " ;<br />                    scount--;    <br />                }   <br />            }<br />        }<br />        cout &lt;&lt; endl;<br />        reset();<br />    }<br />    system("pause");<br />    return 0;    <br />}<br /></code></p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/zerojudge-a010-%e5%9b%a0%e6%95%b8%e5%88%86%e8%a7%a3.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[ACM]412 Pi</title>
		<link>http://eragonj.hax4.in/blog/acm412-pi.html</link>
		<comments>http://eragonj.hax4.in/blog/acm412-pi.html#comments</comments>
		<pubDate>Wed, 21 Jan 2009 22:07:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>
		<category><![CDATA[412]]></category>
		<category><![CDATA[Pi]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=12</guid>
		<description><![CDATA[Tweet 這題比較要注意的地方有以下幾點: 1.先把π的公式由數學式導出來2.要用到數學的排列組合(C X取2這樣)3.算互質的個數4.格式化輸出(精確到小數點下第六位) 心得:在算最後一步的時候(求π時) , 要小心那個double的地方 , 因為int 在算的時候會有拾去的情況 , 最好是都用同個型態去算 , 比較不會出問題 #include &#60;iostream&#62;#include &#60;stdio.h&#62;#include &#60;math.h&#62;using namespace std;int c_num(int i){ return (i*(i-1))/2;}void sort(int arr[],int num){ int i,j; for(i=0;i&#60;num-1;i++){ for(j=i+1;j&#60;num;j++){ if(arr[i]&#60;arr[j]){ swap(arr[i],arr[j]); } } }}void swap(int* a,int* b){ int temp; temp = *a; *a = *b; *b = temp; }int judge(int a,int b){ int [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2Facm412-pi.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/acm412-pi.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/acm412-pi.html"  data-text="[ACM]412 Pi" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p><a href="http://cat.nknush.kh.edu.tw/ZeroJudge/ShowProblem?problemid=c087"></a><br />這題比較要注意的地方有以下幾點:</p>
<p>1.先把π的公式由數學式導出來<br />2.要用到數學的排列組合(C X取2這樣)<br />3.算互質的個數<br />4.格式化輸出(精確到小數點下第六位)</p>
<p>心得:在算最後一步的時候(求π時) , 要小心那個double的地方 , 因為int<br />     在算的時候會有拾去的情況 , 最好是都用同個型態去算 , 比較不會出問題</p>
<p><code><br />#include &lt;iostream&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;math.h&gt;<br />using namespace std;<br />int c_num(int i){<br />    return (i*(i-1))/2;<br />}<br />void sort(int arr[],int num){<br />    int i,j;<br />    for(i=0;i&lt;num-1;i++){<br />        for(j=i+1;j&lt;num;j++){<br />            if(arr[i]&lt;arr[j]){<br />                swap(arr[i],arr[j]);    <br />            }    <br />        }    <br />    }<br />}<br />void swap(int* a,int* b){<br />    int temp;<br />    temp = *a;<br />    *a = *b;<br />    *b = temp;    <br />}<br />int judge(int a,int b){<br />    int max = (a&lt;b)?a:b;<br />    int min = (a&lt;b)?a:b;<br />    int reminder,quotient;<br />    reminder = max%min;<br />    quotient = max/min;<br />    while(reminder!=0){<br />        max = min;<br />        min = reminder;<br />        quotient = max/min;<br />        reminder = max%min;<br />    }<br />    return min;<br />}<br />int main(){</p>
<p>    int i,j,k;<br />    int arr[200],count;<br />    while(cin &gt;&gt; i){<br />        count = 0;<br />        if(i==0){<br />            return 0;    <br />        }else{<br />            for(j=0;j&lt;i;j++){<br />                cin &gt;&gt; arr[j];<br />            }    <br />            sort(arr,i);<br />            for(j=0;j&lt;i-1;j++){<br />                for(k=j+1;k&lt;i;k++){<br />                    if(judge(arr[k],arr[j])==1){<br />                        count++;<br />                    }<br />                }<br />            }<br />            if(count==0){<br />                cout &lt;&lt; "No estimate for this data set." &lt;&lt; endl;<br />            }else{<br />                printf("%.6lfn",sqrt(((double)(6*c_num(i))/count)));  <br />            }<br />        } <br />    }<br />    system("pause");<br />    return 0;    <br />}<br /></code></p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/acm412-pi.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[ACM] 最近在解ACM..</title>
		<link>http://eragonj.hax4.in/blog/%e6%9c%80%e8%bf%91%e5%9c%a8%e8%a7%a3acm.html</link>
		<comments>http://eragonj.hax4.in/blog/%e6%9c%80%e8%bf%91%e5%9c%a8%e8%a7%a3acm.html#comments</comments>
		<pubDate>Wed, 21 Jan 2009 22:04:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[ACM]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=11</guid>
		<description><![CDATA[Tweet 好久沒有解ACM了 , 我發現現在我要解一些題目 , 就感覺比較不會那麼的困擾了 &#8230; 現在是用ZeroJudge的線上解題系統來解題的 , 以後如果有解出的題目 , 除了一些 很簡單的不會放外 (像是什麼物理子彈那種= =) 其他的都會放上來一下:D]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Feragonj.hax4.in%2Fblog%2F%25e6%259c%2580%25e8%25bf%2591%25e5%259c%25a8%25e8%25a7%25a3acm.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://eragonj.hax4.in/blog/%e6%9c%80%e8%bf%91%e5%9c%a8%e8%a7%a3acm.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://eragonj.hax4.in/blog/%e6%9c%80%e8%bf%91%e5%9c%a8%e8%a7%a3acm.html"  data-text="[ACM] 最近在解ACM.." data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>好久沒有解ACM了 , 我發現現在我要解一些題目 , 就感覺比較不會那麼的困擾了 &#8230;</p>
<p>現在是用ZeroJudge的線上解題系統來解題的 , 以後如果有解出的題目 , 除了一些</p>
<p>很簡單的不會放外 (像是什麼物理子彈那種= =)  其他的都會放上來一下:D</p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/%e6%9c%80%e8%bf%91%e5%9c%a8%e8%a7%a3acm.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

