锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲欧美成人久久片 ,精品一区二区久久久久久久网站,亚洲人成精品久久久久http://www.shnenglu.com/Icho/category/14619.htmlSome birds aren`t meant to be caged, their feathers are just too bright... ...zh-cnTue, 17 Aug 2010 22:43:51 GMTTue, 17 Aug 2010 22:43:51 GMT60POJ 1046 Color Me Lesshttp://www.shnenglu.com/Icho/archive/2010/08/18/123773.htmlBrianBrianTue, 17 Aug 2010 17:00:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/18/123773.htmlhttp://www.shnenglu.com/Icho/comments/123773.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/18/123773.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123773.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123773.html
棰樼洰鐨勮姹傛槸杈撳叆鑻ュ共緇勯鑹叉暟鎹紝鍓?6緇勬槸鐩爣緇勶紝鍚庨潰鍓╀笅鐨勯兘鏄敤鏉ュ皾璇曚笌鍏舵槧灝勭殑錛岀敤鍚庨潰涓庡墠闈㈢殑涓嬈″尮閰嶏紝鍚勫驚鐜?6嬈★紝鍚勮嚜鏈灝忕殑D鐨勭浉搴旀槧灝勭粍灝辨槸鎴戜滑瑕佺殑緇撴灉銆?br>
C++ 緙栬瘧鍣?錛?20K  0MS
#include<iostream>
#include
<climits> // 涓虹涓緇勬暟鎹繍綆楀仛鐨勭害鏉?/span>
using namespace std;  
int RGB[16][3],in[3],out[3]; // in 鐢ㄦ潵鎺ユ敹鏁版嵁, out 鐢ㄦ潵鏆傚瓨鏄犲皠姝g‘鐨勬暟鎹?/span>

int main(){ 
    
for (int i=0; i<16; i++// 杈撳叆鐨勬暟鎹腑鍓?6緇勬槸 target set
        cin>>RGB[i][0]>>RGB[i][1]>>RGB[i][2]; 
    
while (1) { 
        cin
>>in[0]>>in[1]>>in[2]; // 寮濮嬫帴鏀舵槧灝勭粍
        if (in[0== -1break;
        
int MIN=INT_MAX; // 2147483647
        for (int i=0; i<16; i++) { 
            
int sum=(RGB[i][0]-in[0])*(RGB[i][0]-in[0])+
                (RGB[i][
1]-in[1])*(RGB[i][1]-in[1])+
                (RGB[i][
2]-in[2])*(RGB[i][2]-in[2]); // 涓嶉渶瑕佸紑鏂癸紝寮鏂規槗浜х敓璇樊
            if (sum < MIN) { 
                
out[0]=RGB[i][0]; 
                
out[1]=RGB[i][1]; 
                
out[2]=RGB[i][2]; 
                MIN
=sum; // 鏈灝忕殑鍗蟲槧灝勬垚鍔?/span>
            } 
        } 
        cout
<<"("<<in[0]<<","<<in[1]<<","<<in[2]<<") maps to ("
            
<<out[0]<<","<<out[1]<<","<<out[2]<<")"<<endl;  
    }
    
return 0;
}

鏈変竴鐐硅璇存槑鐨勬槸<limits.h>澶存枃浠訛紝寤鴻MSDN涓涓嬶紝浣犱細鍙戠幇寰堝鏈夌敤鐨勫父閲忥紝鎷挎潵灝辮兘鐢ㄣ?

Brian 2010-08-18 01:00 鍙戣〃璇勮
]]>
POJ 1045 Bode Plothttp://www.shnenglu.com/Icho/archive/2010/08/17/123728.htmlBrianBrianTue, 17 Aug 2010 06:49:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123728.htmlhttp://www.shnenglu.com/Icho/comments/123728.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123728.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123728.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123728.html鎴戣寰楁湁蹇呰鎶婂畠緲昏瘧涓涓嬶紝鐒跺悗灝變細鍙戠幇鑰冨緱鍏跺疄鏄暟瀛︼紝浣犲湪google 緲昏瘧涓婃槸寰椾笉鍒板涓嬬炕璇戠殑錛?br>Description
鑰冭檻涓嬮潰鐨勪氦嫻佺數璺傛垜浠皢鍋囧畾鐢佃礬鍦ㄧǔ鎬併傚洜姝わ紝鑺傜偣1鐨勭數鍘嬪拰鑺傜偣2鐨勭數鍘嬪垎鍒槸v1 = VS coswt 鍜?v2 = VRcos (wt + q),鍏朵腑Vs鏄數婧愮數鍘嬶紝w鏄鐜?寮у害姣忕)錛宼鏄椂闂淬俈R鏄數闃籖涓ょ鐢靛帇涓嬮檷鐨勫箙搴︼紝q鏄畠鐨勭浉浣嶃?br>POJ 1045 Bode Plot - Icho - Brian Warehouse
浣犻渶瑕佸啓涓涓▼搴忥紝浠ョ‘瀹氫笉鍚岀殑w瀵瑰簲鐨刅R鍊箋傛偍灝嗛渶瑕佷袱涓數瀛﹀畾寰嬫潵瑙e喅榪欎釜闂銆傜涓
涓槸鏄濮嗗畾寰嬶紝琛ㄨ堪涓篤2 = iR錛屽叾涓璱鏄湪鐢佃礬欏烘椂閽堟祦鍚戠殑鐢墊祦澶у皬銆?br>絎簩涓槸i = C d/dt (v1-v2)錛宨涓庣數瀹瑰櫒涓ゆ澘涓婄殑鐢靛帇鏈夊叧銆?d/dt" 鎰忎負姹傚叧浜巘鐨勬眰瀵箋?br>Input
杈撳叆鍖呮嫭涓琛屾垨澶氳銆傜涓琛屽寘鎷笁涓疄鏁板拰涓涓潪璐熸暣鏁般傚疄鏁版寜欏哄簭鏄疺S錛孯錛孋銆?br>鏁存暟n鏄祴璇曠敤渚嬬殑涓暟銆傛帴涓嬫潵鐨刵琛屽氨鏄緭鍏ワ紝瑕佹眰涓琛屼竴涓疄鏁幫紝浠h〃w鐨勫箋?/p>

Output
杈撳嚭n琛岀殑VR鍊鹼紝娉ㄦ剰錛岀粨鏋滅簿紜埌灝忔暟鐐瑰悗涓変綅銆?br>涓嬮潰闇瑕佹帹瀵間竴涓嬫眰VR鐨勫叕寮忥細
V2=iR=CR d/dt (VS*cos(wt)-VR*cos(wt+q))=VRcos(wt+q)
         = CR w (sin(wt+q)-sin(wt))=VRcos(wt+q)
涓嬮潰鐢ㄥ埌楂樹腑鏁板褰撲腑鐨勮綆楁柟娉曪紝鍒嗗埆浠?t=0 鍜?wt+q=0 錛屽緱鍒?CRw  tan b = 1 鍜?VR=CRw VS sin b 錛?/font>
鐒跺悗鍒╃敤涓夎鍑芥暟涓殑涓囪兘鍏紡錛屾眰寰?錛?font color=#ff0000>VR = CRw VS / sqrt (1+ (CRw) ^ 2 ))

POJ 1045 Bode Plot - Icho - Brian Warehouse// C 緙栬瘧鍣?
POJ 1045 Bode Plot - Icho - Brian Warehouse
#include <stdio.h>
POJ 1045 Bode Plot - Icho - Brian Warehouse#include 
<math.h>
POJ 1045 Bode Plot - Icho - Brian Warehouse
int main()
POJ 1045 Bode Plot - Icho - Brian WarehousePOJ 1045 Bode Plot - Icho - Brian Warehouse
POJ 1045 Bode Plot - Icho - Brian Warehouse{
POJ 1045 Bode Plot - Icho - Brian Warehouse    
int i=0,n;
POJ 1045 Bode Plot - Icho - Brian Warehouse    
double VR,VS,R,C,w;
POJ 1045 Bode Plot - Icho - Brian Warehouse    scanf(
"%lf%lf%lf%d",&VS,&R,&C,&n);    
POJ 1045 Bode Plot - Icho - Brian Warehouse    
POJ 1045 Bode Plot - Icho - Brian Warehouse    
for (; i<n; i++)
POJ 1045 Bode Plot - Icho - Brian WarehousePOJ 1045 Bode Plot - Icho - Brian Warehouse    
POJ 1045 Bode Plot - Icho - Brian Warehouse{
POJ 1045 Bode Plot - Icho - Brian Warehouse        scanf(
"%lf",&w);
POJ 1045 Bode Plot - Icho - Brian Warehouse        VR
=C*R*w*VS / sqrt(1+C*C*R*R*w*w);
POJ 1045 Bode Plot - Icho - Brian Warehouse        printf(
"%.3lf\n",VR);
POJ 1045 Bode Plot - Icho - Brian Warehouse    }

POJ 1045 Bode Plot - Icho - Brian Warehouse    
return 0;
POJ 1045 Bode Plot - Icho - Brian Warehouse}

娉ㄦ剰 , 鐢?double 

Brian 2010-08-17 14:49 鍙戣〃璇勮
]]>
澶ф暟闂瀛︿範鍛?2)錛歅OJ Grids 2980 澶ф暣鏁頒箻娉?/title><link>http://www.shnenglu.com/Icho/archive/2010/08/17/123726.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 06:24:00 GMT</pubDate><guid>http://www.shnenglu.com/Icho/archive/2010/08/17/123726.html</guid><wfw:comment>http://www.shnenglu.com/Icho/comments/123726.html</wfw:comment><comments>http://www.shnenglu.com/Icho/archive/2010/08/17/123726.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Icho/comments/commentRss/123726.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Icho/services/trackbacks/123726.html</trackback:ping><description><![CDATA[<span style="COLOR: #000000">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a[</span><span style="COLOR: #000000">200</span><span style="COLOR: #000000">],b[</span><span style="COLOR: #000000">200</span><span style="COLOR: #000000">],c[</span><span style="COLOR: #000000">400</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">},i,j,ls1,ls2;<br>    </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> s;<br>    <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">s,ls1</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s.length(),i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ls1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        a[j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">灝嗙涓涓暟閫嗗簭鏀懼叆a鏁扮粍</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">s,ls2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s.length(),i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ls2</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        b[j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">灝嗙浜屼釜鏁伴嗗簭鏀懼叆b鏁扮粍</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000"><br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">ls1; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">ls2; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            c[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">j] </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> a[i]</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">b[j];<br>            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(c[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">j] </span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">)<br>            {<br>                c[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">j</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">] </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> c[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">j]</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">;<br>                c[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">j] </span><span style="COLOR: #000000">%=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">;<br>            }<br>        }<br>    <br>    i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">399</span><span style="COLOR: #000000">;<br>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (c[i]) </span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">璺寵繃鎵鏈夊墠瀵?</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (; i</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,c[i]); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">杈撳嚭涓諱綋閮ㄥ垎</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}<br></span> <img src ="http://www.shnenglu.com/Icho/aggbug/123726.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Icho/" target="_blank">Brian</a> 2010-08-17 14:24 <a href="http://www.shnenglu.com/Icho/archive/2010/08/17/123726.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>澶ф暟闂瀛︿範鍛?1)錛歅OJ Grids 2981 澶ф暣鏁板姞娉?/title><link>http://www.shnenglu.com/Icho/archive/2010/08/17/123725.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 06:21:00 GMT</pubDate><guid>http://www.shnenglu.com/Icho/archive/2010/08/17/123725.html</guid><wfw:comment>http://www.shnenglu.com/Icho/comments/123725.html</wfw:comment><comments>http://www.shnenglu.com/Icho/archive/2010/08/17/123725.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Icho/comments/commentRss/123725.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Icho/services/trackbacks/123725.html</trackback:ping><description><![CDATA[<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 12pt; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #000000">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> a[</span><span style="COLOR: #000000">201</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">},b[</span><span style="COLOR: #000000">200</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">{</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">},i,j,len,ls1,ls2,f</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 鐩稿姞鍚庣粨鏋滄斁鍦╝鍐?/span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000"> s;<br>    <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">s,ls1</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s.length(),i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ls1</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        a[j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">灝嗙涓涓暟閫嗗簭鏀懼叆a鏁扮粍</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">s,ls2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s.length(),i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ls2</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        b[j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">s[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">灝嗙浜屼釜鏁伴嗗簭鏀懼叆b鏁扮粍</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000"><br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,len</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">ls1</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">ls2</span><span style="COLOR: #000000">?</span><span style="COLOR: #000000">ls1:ls2; i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">len; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 娉ㄦ剰len鍙栦簩鑰呰緝澶х殑鍊?/span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    {<br>        a[i] </span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000"> b[i]; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鐩稿姞緇撴灉鏀懼叆a鏁扮粍</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (a[i] </span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">)<br>        {<br>            a[i] </span><span style="COLOR: #000000">%=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">榪涗綅澶勭悊</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">            a[i</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>        }<br>    }<br>    <br>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (a[len]) printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,a[len]); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鎵璋撶殑鍓嶅0</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">len</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,a[i]); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">杈撳嚭涓諱綋閮ㄥ垎</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}</span></div> <img src ="http://www.shnenglu.com/Icho/aggbug/123725.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Icho/" target="_blank">Brian</a> 2010-08-17 14:21 <a href="http://www.shnenglu.com/Icho/archive/2010/08/17/123725.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>POJ-grids 2808 鏍¢棬澶栫殑鏍?/title><link>http://www.shnenglu.com/Icho/archive/2010/08/17/123724.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 06:19:00 GMT</pubDate><guid>http://www.shnenglu.com/Icho/archive/2010/08/17/123724.html</guid><wfw:comment>http://www.shnenglu.com/Icho/comments/123724.html</wfw:comment><comments>http://www.shnenglu.com/Icho/archive/2010/08/17/123724.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Icho/comments/commentRss/123724.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Icho/services/trackbacks/123724.html</trackback:ping><description><![CDATA[<dl> <dt>棰樼洰鎻忚堪 <dd>鏌愭牎澶ч棬澶栭暱搴︿負L鐨勯┈璺笂鏈変竴鎺掓爲錛屾瘡涓ゆ5鐩擱偦鐨勬爲涔嬮棿鐨勯棿闅旈兘鏄?綾熾傛垜浠彲浠ユ妸椹礬鐪嬫垚涓涓暟杞達紝椹礬鐨勪竴绔湪鏁拌醬0鐨勪綅緗紝鍙︿竴绔湪L鐨勪綅緗紱鏁拌醬涓婄殑姣忎釜鏁存暟鐐癸紝鍗?錛?錛?錛?#8230;…錛孡錛岄兘縐嶆湁涓媯墊爲銆?br>椹礬涓婃湁涓浜涘尯鍩熻鐢ㄦ潵寤哄湴閾侊紝榪欎簺鍖哄煙鐢ㄥ畠浠湪鏁拌醬涓婄殑璧峰鐐瑰拰緇堟鐐硅〃紺恒傚凡鐭ヤ換涓鍖哄煙鐨勮搗濮嬬偣鍜岀粓姝㈢偣鐨勫潗鏍囬兘鏄暣鏁幫紝鍖哄煙涔嬮棿鍙兘鏈夐噸鍚堢殑閮ㄥ垎銆傜幇鍦ㄨ鎶婅繖浜涘尯鍩熶腑鐨勬爲錛堝寘鎷尯鍩熺鐐瑰鐨勪袱媯墊爲錛夌Щ璧般備綘鐨勪換鍔℃槸璁$畻灝嗚繖浜涙爲閮界Щ璧板悗錛岄┈璺笂榪樻湁澶氬皯媯墊爲銆?br> <dt>杈撳叆 <dd>杈撳叆鐨勭涓琛屾湁涓や釜鏁存暟L錛? <= L <= 10000錛夊拰 M錛? <= M <= 100錛夛紝L浠h〃椹礬鐨勯暱搴︼紝M浠h〃鍖哄煙鐨勬暟鐩紝L鍜孧涔嬮棿鐢ㄤ竴涓┖鏍奸殧寮銆傛帴涓嬫潵鐨凪琛屾瘡琛屽寘鍚袱涓笉鍚岀殑鏁存暟錛岀敤涓涓┖鏍奸殧寮錛岃〃紺轟竴涓尯鍩熺殑璧峰鐐瑰拰緇堟鐐圭殑鍧愭爣銆? <dt>杈撳嚭 <dd>杈撳嚭鍖呮嫭涓琛岋紝榪欎竴琛屽彧鍖呭惈涓涓暣鏁幫紝琛ㄧず椹礬涓婂墿浣欑殑鏍戠殑鏁扮洰銆? <dt>鏍蜂緥杈撳叆 <dd> <pre>500 3 150 300 100 200 470 471 </pre> <dt>鏍蜂緥杈撳嚭 <dd> <pre>298</pre> </dd></dl> <pre>鍩烘湰鎬濊礬錛氬皢鎵鏈夌殑鏍戝仛鏍囪錛岀Щ璧板垯鏍囪涓?錛屽瓨鍦ㄦ爣璁頒負1.鐢變簬涓嶅ソ鍒ゆ柇緇欏畾鏁扮洰鏄灝戯紝鏁呯敤鍚戦噺銆傛晥鐜囪櫧鐒朵笉楂橈紝浣嗘槸鍙互AC銆?/pre> <pre> <div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 12pt; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #000000">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br>#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> L,M,i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,j,start,end,count</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">L,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">M);<br>    vector</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> Mark(L</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br>    <br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (; i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">M; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) <br>    {<br>        scanf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d%d</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">start,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">end);<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">start; j</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">end; j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            Mark[j]</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>    }<br>    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; i</span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000">L; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (Mark[i]</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br>            count</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br>    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,count);<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}</span></div> </pre> <pre> </pre> <img src ="http://www.shnenglu.com/Icho/aggbug/123724.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Icho/" target="_blank">Brian</a> 2010-08-17 14:19 <a href="http://www.shnenglu.com/Icho/archive/2010/08/17/123724.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>POJ Grids 2798 2榪涘埗杞寲涓?6榪涘埗http://www.shnenglu.com/Icho/archive/2010/08/17/123723.htmlBrianBrianTue, 17 Aug 2010 06:18:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123723.htmlhttp://www.shnenglu.com/Icho/comments/123723.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123723.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123723.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123723.htmlDescription

杈撳叆涓涓?榪涘埗鐨勬暟錛岃姹傝緭鍑鴻2榪涘埗鏁扮殑16榪涘埗琛ㄧず銆?
鍦?6榪涘埗鐨勮〃紺轟腑錛孉-F琛ㄧず10-15

Input

絎?琛屾槸嫻嬭瘯鏁版嵁鐨勭粍鏁皀錛屽悗闈㈣窡鐫n琛岃緭鍏ャ傛瘡緇勬祴璇曟暟鎹崰1琛岋紝鍖呮嫭涓涓互0鍜?緇勬垚鐨勫瓧絎︿覆錛屽瓧絎︿覆闀垮害鑷沖皯鏄?錛岃嚦澶氭槸10000

Output

n琛岋紝姣忚杈撳嚭瀵瑰簲涓涓緭鍏ャ?/font>

Sample Input

2
100000
111

 

 

 

Sample Output

20
7


09灝忓闂垜鐨勪竴閬撻錛屽師鏉ュ啓鐨勪唬鐮佽凍瓚蟲湁90澶氳錛屼粖澶╅噸鍐欙細
 
#include <iostream>
#include 
<string>
using namespace std;

int main()
{
    
int n,pos,sec,i,j,w[4= {1,2,4,8}; //sec鏄垎孌靛鐞?pos鏄搴旀潈鍊間綅緗?/span>
    char x[17= "0123456789ABCDEF"//鎵撹〃        
    string bin; //杈撳叆鐨勪簩榪涘埗瀛楃涓?/span>
    cin>>n;
    
while (n--)
    {
        cin
>>bin;
        sec
=bin.length()%4;
        pos
=0;
        
for (i=sec; i>0; i--)
            
if (bin[sec-i]=='1')
                pos 
+= w[i-1];
        
if (sec) printf("%c",x[pos]);
        
for (i=sec; i<bin.length(); i+=4)
        {
            pos
=0;
            
for (j=0; j<4; j++)
                
if (bin[i+j]=='1')
                    pos 
+= w[3-j];
            printf(
"%c",x[pos]);
        }
        printf(
"\n");
    }
    
return 0;
}


Brian 2010-08-17 14:18 鍙戣〃璇勮
]]>
POJ Grids 2745 鏄劇ず鍣?/title><link>http://www.shnenglu.com/Icho/archive/2010/08/17/123722.html</link><dc:creator>Brian</dc:creator><author>Brian</author><pubDate>Tue, 17 Aug 2010 06:17:00 GMT</pubDate><guid>http://www.shnenglu.com/Icho/archive/2010/08/17/123722.html</guid><wfw:comment>http://www.shnenglu.com/Icho/comments/123722.html</wfw:comment><comments>http://www.shnenglu.com/Icho/archive/2010/08/17/123722.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Icho/comments/commentRss/123722.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Icho/services/trackbacks/123722.html</trackback:ping><description><![CDATA[<p align=left><strong><font color=#333399 size=5>Description</font> </strong></p> <p><font size=3 face="Times New Roman">浣犵殑涓涓湅鍙嬩拱浜嗕竴鍙扮數鑴戙備粬浠ュ墠鍙敤榪囪綆楀櫒錛屽洜涓虹數鑴戠殑鏄劇ず鍣ㄤ笂鏄劇ず鐨勬暟瀛楃殑鏍峰瓙鍜岃綆楀櫒鏄笉涓鏍鳳紝鎵浠ュ綋浠栦嬌鐢ㄧ數鑴戠殑鏃跺欎細姣旇緝閮侀椃銆備負浜嗗府鍔╀粬錛屼綘鍐沖畾鍐欎竴涓▼搴忔妸鍦ㄧ數鑴戜笂鐨勬暟瀛楁樉紺哄緱鍍忚綆楀櫒涓婁竴鏍楓?/font></p> <p align=left><strong><font color=#333399 size=5>Input</font> </strong></p> <p><font size=3 face="Times New Roman">杈撳叆鍖呮嫭鑻ュ共琛岋紝姣忚琛ㄧず涓涓鏄劇ず鐨勬暟銆傛瘡琛屾湁涓や釜鏁存暟s鍜宯 (1 <= s <= 10, 0 <= n <= 99999999)錛岃繖閲宯鏄鏄劇ず鐨勬暟錛宻鏄鏄劇ず鐨勬暟鐨勫昂瀵搞?<br><br>濡傛灉鏌愯杈撳叆鍖呮嫭涓や釜0錛岃〃紺鴻緭鍏ョ粨鏉熴傝繖琛屼笉闇瑕佸鐞嗐?<br></font></p> <p align=left><strong><font color=#333399 size=5>Output</font> </strong></p> <p><font size=3 face="Times New Roman">鏄劇ず鐨勬柟寮忔槸錛氱敤s涓?-'琛ㄧず涓涓按騫崇嚎孌碉紝鐢╯涓?|'琛ㄧず涓涓瀭鐩寸嚎孌點傝繖縐嶆儏鍐典笅錛屾瘡涓涓暟瀛楅渶瑕佸崰鐢╯+2鍒楀拰2s+3琛屻傚彟澶栵紝鍦ㄤ袱涓暟瀛椾箣闂磋杈撳嚭涓涓┖鐧界殑鍒椼傚湪杈撳嚭瀹屾瘡涓涓暟涔嬪悗錛岃緭鍑轟竴涓┖鐧界殑琛屻傛敞鎰忥細杈撳嚭涓┖鐧界殑鍦版柟閮借鐢ㄧ┖鏍兼潵濉厖銆?<br></font></p> <p align=left><strong><font color=#333399 size=5>Sample Input</font> </strong></p> <p><font size=3 face="Times New Roman"></p> <pre>2 12345 3 67890 0 0 </pre> </font> <p> </p> <p> </p> <p align=left><strong><font color=#333399 size=5>Sample Output</font> </strong></p> <p><font size=3 face="Times New Roman"></p> <pre> -- -- -- | | | | | | | | | | | | -- -- -- -- | | | | | | | | | | -- -- -- --- --- --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- --- </pre> </font> <p> </p> <p> </p> <p align=left><strong><font color=#333399 size=5>Hint</font> </strong></p> <p><font size=3 face="Times New Roman">鏁板瓧(digit)鎸囩殑鏄?錛屾垨鑰?錛屾垨鑰?……鎴栬?銆?<br>鏁?number)鐢變竴涓垨鑰呭涓暟瀛楃粍鎴愩?</font></p> <p style="TEXT-INDENT: 2em">榪欓妯法鎴戜竴涓鏈熶箣涔咃紝鍚庢潵鏃犲榪樻槸鐧懼害浜嗕竴涓嬶細</p> <div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 12pt; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><span style="COLOR: #000000">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br><br></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> n1[] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">- -- -----</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> n2[] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">|   ||| ||</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> n3[] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">|||||  |||</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> n4[] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">  ----- --</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> n5[] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">| |   | | </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> n6[] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">|| |||||||</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> n7[] </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">- -- -- --</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><br></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()<br>{<br>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> m;<br>    </span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> n[</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">];<br>    cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">m</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">n;<br>    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> ((n[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">||</span><span style="COLOR: #000000">m)<br>    {<br>        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> len </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> strlen(n);<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">len;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>            </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> n[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">m;j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            {<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n1[num];<br>            }<br>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>        }<br>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> temp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> m;<br>        </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (temp</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        {<br>            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">len;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            {<br>                </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> n[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n2[num];<br>                </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">m;j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>                {<br>                    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>                }<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n3[num];<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>            }<br>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>        }<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">len;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>            </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> n[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">m;j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            {<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n4[num];<br>            }<br>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>        }<br>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>        temp </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> m;<br>        </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> (temp</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)<br>        {<br>            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">len;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            {<br>                </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> n[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n5[num];<br>                </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">m;j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>                {<br>                    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>                }<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n6[num];<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>            }<br>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br>        }<br>        </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">len;i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>        {<br>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>            </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> num </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> n[i]</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br>            </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> j</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;j</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">m;j</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br>            {<br>                cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">n7[num];<br>            }<br>            cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">  </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br>        }<br>        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><br>        cin</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">m</span><span style="COLOR: #000000">>></span><span style="COLOR: #000000">n;<br>    }<br>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br>}<br></span></div> <p> </p> <p>鎴戞兂錛岀涓嬈″仛鍑烘潵榪欓鐨勪漢鐪熸槸浜嗕笉璧鳳紒</p> <img src ="http://www.shnenglu.com/Icho/aggbug/123722.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Icho/" target="_blank">Brian</a> 2010-08-17 14:17 <a href="http://www.shnenglu.com/Icho/archive/2010/08/17/123722.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>POJ 1008 Maya Calendarhttp://www.shnenglu.com/Icho/archive/2010/08/17/123721.htmlBrianBrianTue, 17 Aug 2010 06:16:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123721.htmlhttp://www.shnenglu.com/Icho/comments/123721.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123721.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123721.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123721.html
#include<stdio.h>
#include
<string.h>
char hm[19][7]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax",
                
"zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char tm[20][9]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok",
                
"chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int main()
{
    
int i,m,n,day,year;
    
char month[9];    
    scanf(
"%d",&n);
    printf(
"%d\n",n);
    
    
while (n--)
    {
        scanf(
"%d.%s%d",&day,month,&year);
        
for(i=0; i<19; i++)
            
if(strcmp(hm[i],month) == 0)
            {
                m
=365*year+20*i+day;
                
break;
            }
        printf(
"%d %s %d\n",m%260%13+1,tm[m%20],m/260);
    }
    
return 0;
}


Brian 2010-08-17 14:16 鍙戣〃璇勮
]]>
POJ 1007 DNA sortinghttp://www.shnenglu.com/Icho/archive/2010/08/17/123720.htmlBrianBrianTue, 17 Aug 2010 06:12:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123720.htmlhttp://www.shnenglu.com/Icho/comments/123720.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123720.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123720.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123720.html姝ょ▼搴忚楄垂鎴戝敖3涓皬鏃朵箣涔咃紝鍘熷洜鏄仛棰樺墠鐨勮鍒掓病鍋氬ソ錛屼竴鐩存病鏈夋兂鍒版暣浣撴帓搴忕殑濂藉姙娉曪紝鏈鍚庤繕鏄敤浜嗘敞鎰忓尮閰嶇殑鏂規硶鎵嶈В鍐充簡闂錛屾垜涓嶇煡閬撲負浠涔堢敤鍐掓場涓嶈錛岀涓涓瓧絎︿覆鎬繪槸涔辯爜銆傛垜瑙夊緱鏁翠綋鎬濊礬榪樻槸姣旇緝娓呮櫚鐨勶紝鍙槸鏂規硶鍙兘鏈夌偣鍌伙紝鏁堢巼榪樿銆?
C 緙栬瘧鍣?: 172K    0MS
POJ 1007 DNA sorting - Icho - Brian Warehouse#include <stdio.h>
POJ 1007 DNA sorting - Icho - Brian Warehouse#include 
<string.h>
POJ 1007 DNA sorting - Icho - Brian Warehouse
POJ 1007 DNA sorting - Icho - Brian Warehousetypedef 
struct DNA
POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
POJ 1007 DNA sorting - Icho - Brian Warehouse{
POJ 1007 DNA sorting - Icho - Brian Warehouse    
char str[50]; // 瀛樺偍瀛楃涓?/span>
POJ 1007 DNA sorting - Icho - Brian Warehouse
    int count[2]; // [0] [1]閮藉瓨鏀句覆鐨勯嗗簭鏁?nbsp;
POJ 1007 DNA sorting - Icho - Brian Warehouse
}
DNA;              // [1]涓綔涓哄弬鑰?鐢ㄦ潵鍜屾帓搴忓悗鐨刐0]鍖歸厤
POJ 1007 DNA sorting - Icho - Brian Warehouse

POJ 1007 DNA sorting - Icho - Brian Warehouse
int main()
POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
POJ 1007 DNA sorting - Icho - Brian Warehouse{
POJ 1007 DNA sorting - Icho - Brian Warehouse    
int i=0,j,k=0,n,m,temp;
POJ 1007 DNA sorting - Icho - Brian Warehouse    DNA or[
100];
POJ 1007 DNA sorting - Icho - Brian Warehouse    scanf(
"%d%d",&n,&m);
POJ 1007 DNA sorting - Icho - Brian Warehouse    
POJ 1007 DNA sorting - Icho - Brian Warehouse    
while (k<m) //鑾峰緱鏁版嵁騫舵眰鍚勮嚜閫嗗簭鏁?/span>
POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
    POJ 1007 DNA sorting - Icho - Brian Warehouse{
POJ 1007 DNA sorting - Icho - Brian Warehouse        scanf(
"%s",&or[k].str);
POJ 1007 DNA sorting - Icho - Brian Warehouse        or[k].count[
0]=0// 姝ゆ涓嶈兘蹇?/span>
POJ 1007 DNA sorting - Icho - Brian Warehouse
        for (i=0; i<n; i++)
POJ 1007 DNA sorting - Icho - Brian Warehouse            
for (j=i+1; j<n; j++)
POJ 1007 DNA sorting - Icho - Brian Warehouse                
if (or[k].str[i] > or[k].str[j])
POJ 1007 DNA sorting - Icho - Brian Warehouse                    or[k].count[
0]++;
POJ 1007 DNA sorting - Icho - Brian Warehouse        k
++;
POJ 1007 DNA sorting - Icho - Brian Warehouse    }

POJ 1007 DNA sorting - Icho - Brian Warehouse    
POJ 1007 DNA sorting - Icho - Brian Warehouse    
for (i=0; i<m; i++)
POJ 1007 DNA sorting - Icho - Brian Warehouse        or[i].count[
1]=or[i].count[0]; // 鍘熼嗗簭鏁板瓨鏀鵑『搴?/span>
POJ 1007 DNA sorting - Icho - Brian Warehouse

POJ 1007 DNA sorting - Icho - Brian Warehouse    
for (i=1; i<m; i++// 瀵逛簬鍚勭粍涓茬殑閫嗗簭鏁拌繘琛屾帓搴?count[0]鍐呭宸叉墦涔?/span>
POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
    POJ 1007 DNA sorting - Icho - Brian Warehouse{
POJ 1007 DNA sorting - Icho - Brian Warehouse        k
=i-1;
POJ 1007 DNA sorting - Icho - Brian Warehouse        
for (j=i; j<m; j++)
POJ 1007 DNA sorting - Icho - Brian Warehouse            
if (or[j].count[0< or[k].count[0])
POJ 1007 DNA sorting - Icho - Brian Warehouse                k
=j;
POJ 1007 DNA sorting - Icho - Brian Warehouse        
POJ 1007 DNA sorting - Icho - Brian Warehouse        temp
=or[i-1].count[0];
POJ 1007 DNA sorting - Icho - Brian Warehouse        or[i
-1].count[0]=or[k].count[0];
POJ 1007 DNA sorting - Icho - Brian Warehouse        or[k].count[
0]=temp;
POJ 1007 DNA sorting - Icho - Brian Warehouse    }
                // 榪欐槸鍏稿瀷鐨勯夋嫨鎺掑簭,鍙槸瀵筟0]鍗曞厓鐨勫鐞?紼沖畾涓庡惁娌″叧緋?/span>
POJ 1007 DNA sorting - Icho - Brian Warehouse
  
POJ 1007 DNA sorting - Icho - Brian Warehouse
POJ 1007 DNA sorting - Icho - Brian Warehouse    
for (i=0; i<m; i++)
POJ 1007 DNA sorting - Icho - Brian Warehouse        
for (j=0; j<m; j++)
POJ 1007 DNA sorting - Icho - Brian Warehouse            
if (or[i].count[0== or[j].count[1]) // [0] 鍜?nbsp;[1] 涓愪竴鐩告瘮杈?/span>
POJ 1007 DNA sorting - Icho - Brian WarehousePOJ 1007 DNA sorting - Icho - Brian Warehouse
            POJ 1007 DNA sorting - Icho - Brian Warehouse{
POJ 1007 DNA sorting - Icho - Brian Warehouse                or[j].count[
1]=-1// 姝ゆ鏄浉絳夋椂欏哄簭涓嶅彉鐨勪繚璇?鐩稿綋浜庡仛浜嗚闂爣璁?
POJ 1007 DNA sorting - Icho - Brian Warehouse
                printf("%s\n",or[j].str);
POJ 1007 DNA sorting - Icho - Brian Warehouse            }

POJ 1007 DNA sorting - Icho - Brian Warehouse
POJ 1007 DNA sorting - Icho - Brian Warehouse    
return 0;
POJ 1007 DNA sorting - Icho - Brian Warehouse}


Brian 2010-08-17 14:12 鍙戣〃璇勮
]]>
POJ 1006 Biorhythmshttp://www.shnenglu.com/Icho/archive/2010/08/17/123719.htmlBrianBrianTue, 17 Aug 2010 06:10:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123719.htmlhttp://www.shnenglu.com/Icho/comments/123719.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123719.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123719.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123719.html闃呰鐞嗚В棰?/strong> , 璇繪噦鎰忔濆熀鏈笂鎬濊礬灝卞嚭鏉ヤ簡錛屾伆宸у張鏄竴閬撲腑鏂囬錛岃繖閲岀敤鏋氫婦錛屽叾浠栦笉瑙i噴銆?br>

POJ 1006 Biorhythms - Icho - Brian Warehouse#include <stdio.h>
POJ 1006 Biorhythms - Icho - Brian Warehouse
int main()
POJ 1006 Biorhythms - Icho - Brian WarehousePOJ 1006 Biorhythms - Icho - Brian Warehouse
POJ 1006 Biorhythms - Icho - Brian Warehouse{
POJ 1006 Biorhythms - Icho - Brian Warehouse    
int i,a,b,c,d,days=0;
POJ 1006 Biorhythms - Icho - Brian Warehouse    
while(1)
POJ 1006 Biorhythms - Icho - Brian WarehousePOJ 1006 Biorhythms - Icho - Brian Warehouse    
POJ 1006 Biorhythms - Icho - Brian Warehouse{
POJ 1006 Biorhythms - Icho - Brian Warehouse        days
++;
POJ 1006 Biorhythms - Icho - Brian Warehouse        scanf(
"%d%d%d%d",&a,&b,&c,&d);
POJ 1006 Biorhythms - Icho - Brian Warehouse        
if (a+b+c+== -4break;
POJ 1006 Biorhythms - Icho - Brian Warehouse        
for (i=d+1; ; i++// pay attention: from d+1
POJ 1006 Biorhythms - Icho - Brian WarehousePOJ 1006 Biorhythms - Icho - Brian Warehouse
        POJ 1006 Biorhythms - Icho - Brian Warehouse{
POJ 1006 Biorhythms - Icho - Brian Warehouse            
if ((i-a)%23==0)
POJ 1006 Biorhythms - Icho - Brian Warehouse                
if ((i-b)%28==0)
POJ 1006 Biorhythms - Icho - Brian Warehouse                    
if ((i-c)%33==0)
POJ 1006 Biorhythms - Icho - Brian WarehousePOJ 1006 Biorhythms - Icho - Brian Warehouse                    
POJ 1006 Biorhythms - Icho - Brian Warehouse{
POJ 1006 Biorhythms - Icho - Brian Warehouse                        printf(
"Case %d: the next triple peak occurs in %ld days.\n",days,i-d);
POJ 1006 Biorhythms - Icho - Brian Warehouse                        
break;
POJ 1006 Biorhythms - Icho - Brian Warehouse                    }

POJ 1006 Biorhythms - Icho - Brian Warehouse        }

POJ 1006 Biorhythms - Icho - Brian Warehouse    }

POJ 1006 Biorhythms - Icho - Brian Warehouse    
return 0;
POJ 1006 Biorhythms - Icho - Brian Warehouse}


Brian 2010-08-17 14:10 鍙戣〃璇勮
]]>
POJ 1005 I Think I Need a Houseboathttp://www.shnenglu.com/Icho/archive/2010/08/17/123718.htmlBrianBrianTue, 17 Aug 2010 06:09:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123718.htmlhttp://www.shnenglu.com/Icho/comments/123718.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123718.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123718.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123718.htmlDescription

Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the state of Louisiana is actually shrinking by 50 square miles each year, due to erosion caused by the Mississippi River. Since Fred is hoping to live in this house the rest of his life, he needs to know if his land is going to be lost to erosion.

After doing more research, Fred has learned that the land that is being lost forms a semicircle. This semicircle is part of a circle centered at (0,0), with the line that bisects the circle being the X axis. Locations below the X axis are in the water. The semicircle has an area of 0 at the beginning of year 1. (Semicircle illustrated in the Figure.)

POJ 1005 I Think I Need a Houseboat - Icho - Brian Warehouse

Input

The first line of input will be a positive integer indicating how many data sets will be included (N). Each of the next N lines will contain the X and Y Cartesian coordinates of the land Fred is considering. These will be floating point numbers measured in miles. The Y coordinate will be non-negative. (0,0) will not be given.

Output

For each data set, a single line of output should appear. This line should take the form of: “Property N: This property will begin eroding in year Z.” Where N is the data set (counting from 1), and Z is the first year (start from 1) this property will be within the semicircle AT THE END OF YEAR Z. Z must be an integer. After the last data set, this should print out “END OF OUTPUT.”
 
鎶婇鎰忓紕鏄庣櫧錛屽氨鐭ラ亾榪欓亾棰樻槸姘撮浜嗭紝鐢卞潗鏍?(0,0) 寮濮嬶紝浠ュ崐鍦嗕負褰㈢姸姣忓勾渚佃殌50 騫蟲柟 miles 錛岄棶浣犱粠 (0,0) 寮濮嬪埌 (x,y) 緇撴潫闇瑕佸闀挎椂闂達紝姘撮涓嶉渶瑕佸お鍏蟲敞鏁堢巼錛屾墍浠ュ彉閲忓畾涔変笂娌℃湁娣辯┒錛屽叾浠栦笉瑙i噴銆?/div>
緙栬瘧鍣?nbsp;C + + :
#include <iostream>
using namespace std;
#define PI 3.1415926
int main()
{
     int n,i=0,year;
  double x,y,area;     
     cin>>n;
     while (i<n)
  {
         cin>>x>>y;
         area = 0.5 * PI * (x*x+y*y); // semicircle area equation
         year = area/50;
         printf("Property %d: This property will begin eroding in year %d.\n",i+1,year+1);
   i++;
     }
     printf("END OF OUTPUT.\n");
  return 0;
}


Brian 2010-08-17 14:09 鍙戣〃璇勮
]]>POJ 1004 Financial Managementhttp://www.shnenglu.com/Icho/archive/2010/08/17/123717.htmlBrianBrianTue, 17 Aug 2010 06:06:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123717.htmlhttp://www.shnenglu.com/Icho/comments/123717.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123717.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123717.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123717.html姝e畻姘撮錛屽氨鏄緭鍏?2涓誕鐐規暟錛岃浣犳眰騫沖潎鍊鹼紝涓嶈В閲娿?/p>

#include<stdio.h>

int main()

{

 float i=0,m,s=0;

 for(;i<12;i++)

 {

  scanf("%f",&m);

  s+=m;  

 }

 printf("$%.2f\n",s/12);

 return 0;

}



Brian 2010-08-17 14:06 鍙戣〃璇勮
]]>
POJ 1003 Hangoverhttp://www.shnenglu.com/Icho/archive/2010/08/17/123715.htmlBrianBrianTue, 17 Aug 2010 06:05:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123715.htmlhttp://www.shnenglu.com/Icho/comments/123715.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123715.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123715.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123715.html姝e畻姘撮錛岄鐩妸鏈涓昏鐨勫叕寮忛兘緇欎綘浜嗭紝鍙璁$畻1/2+1/3+1/4+......+1/(n+1) >= x涓渶灝忕殑n鍊煎嵆鍙紝鎴戣繖閲岀殑cards鐢ㄧ殑鏄暣褰紝娉ㄦ剰搴曚笅涓瀹氳涔樹互1.0錛屽惁鍒欎細璁╀綘璋冭瘯鐨勭敓涓嶅姝葷殑錛岃涓嶄綘灝辮cards 鏄誕鐐瑰瀷錛屽叾浠栫殑涓嶈В閲娿?br>#include<stdio.h>

int main()
{
 int cards;
 float length,c;
 for(scanf("%f",&c); c!=0.0; scanf("%f",&c))
 {
  for(cards=0,length=0; length<c; )
  {
   cards++;
   length+=1/(cards*1.0+1);
  }
  printf("%d card(s)\n",cards);  
 }
    return 0;
} //180K  0MS



Brian 2010-08-17 14:05 鍙戣〃璇勮
]]>
POJ 1002 487-3279http://www.shnenglu.com/Icho/archive/2010/08/17/123714.htmlBrianBrianTue, 17 Aug 2010 06:04:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123714.htmlhttp://www.shnenglu.com/Icho/comments/123714.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123714.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123714.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123714.html浜嬪厛鐢蟲槑錛岃紼嬪簭铏界劧AC錛屼絾鏄晥鐜囨瀬鍏朵綆涓嬶紝浣庝笅鍒拌浜哄彂鎸囩殑紼嬪害錛屾垜涔熶笉鐭ラ亾涓轟粈涔堛備及璁℃槸鐢ㄤ簡STL鐨勫師鍥狅紝鍏蜂綋鎴戜篃璇翠笉娓呮銆傚叾瀹炴濊礬涓嶉毦錛屽氨鏄皢瀛楃杞寲鎴愬搴旀暟瀛楋紝鐒跺悗灝嗙粨鏋滃瓨鏀懼湪涓涓暣鍨嬪悜閲忎腑錛屾帴鏀跺瓧絎︿覆鐢ㄧ殑鏄瓧絎︿覆鍚戦噺錛屽鐞嗙殑鏃跺欒窡涓鑸殑瀛楃涓插鐞嗘椂涓妯′竴鏍風殑銆傚鐞嗙粨鏉熶箣鍚庤榪涜瀛楀吀鎺掑簭錛屾樉鐒惰鐢ㄦ帓搴忓嚱鏁幫紝鍙互鐢ㄥ啋娉★紝閫夋嫨錛屽揩鎺掞紝鐢氳嚦鏄疕ash錛屼絾鏄嵁璇碨TL鐨剆ort 鏁堢巼姣斿揩鎺掕繕瑕佸揩銆傛簮紼嬪簭鍚庨檮鍔犱簡MSDN涓婄殑涓浜涚畝鍗曡В閲娿傛病鏈夌炕璇戯紒

Description

Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino's by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens'' number 3-10-10-10.

The standard form of a telephone number is seven decimal digits with a hyphen between the third and fourth digits (e.g. 888-1200). The keypad of a phone supplies the mapping of letters to numbers, as follows:

A, B, and C map to 2
D, E, and F map to 3
G, H, and I map to 4
J, K, and L map to 5
M, N, and O map to 6
P, R, and S map to 7
T, U, and V map to 8
W, X, and Y map to 9

There is no mapping for Q or Z. Hyphens are not dialed, and can be added and removed as necessary. The standard form of TUT-GLOP is 888-4567, the standard form of 310-GINO is 310-4466, and the standard form of 3-10-10-10 is 310-1010.

Two telephone numbers are equivalent if they have the same standard form. (They dial the same number.)

Your company is compiling a directory of telephone numbers from local businesses. As part of the quality control process you want to check that no two (or more) businesses in the directory have the same telephone number.

Input

The input will consist of one case. The first line of the input specifies the number of telephone numbers in the directory (up to 100,000) as a positive integer alone on the line. The remaining lines list the telephone numbers in the directory, with each number alone on a line. Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters.

Output

Generate a line of output for each telephone number that appears more than once in any form. The line should give the telephone number in standard form, followed by a space, followed by the number of times the telephone number appears in the directory. Arrange the output lines by telephone number in ascending lexicographical order. If there are no duplicates in the input print the line:
No duplicates.

C++ 緙栬瘧鍣?

#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // STL sort function
using namespace std;

char map[] = "2223334445556667#77888999#";
                  //ABCDEFGHIJKLMNOPQRSTUVWXYZ
void visited(char &ch) // visit and format strings
{
   if (ch >= 'A' && ch <= 'Z')
    ch=map[ch-'A']; // ch equals to its real number
}

int main()
{
    int N,i=0,j,flag=0;
 string s;
 vector<string> stored(100000); // be visited & stored (up to 100,000)
    cin>>N;
 vector<int> counter(N,1); // stored times
   
 for (; i<N; i++)
 {
  cin>>s;
  for (j=0; j<s.length(); j++) // MSDN
  {
   visited(s[j]);
   if (s[j]!='-')
   {
    stored[i] += s[j];
    if (stored[i].length()==3)
     stored[i] += '-'; // 487 -[3] 3279
   }
  }
 }
    sort(stored.begin(),stored.begin()+N); // Quicker than QuickSort!
 // should not used stored.end() !
 i=0; j=1;
    while (i<N)
 {
  while(stored[i] == stored[j])
  {
   counter[i]++;
   j++;
   flag=1;
  }
  i=j;
  j++;
 }
 
    if (flag)
  for (i=0; i<N; i++)
  {
   if (counter[i]>1)
    cout<<stored[i]<<" "<<counter[i]<<endl;
  } // must have { }
 else cout<<"No duplicates."<<endl;
  
 return 0;
}

Sort 錛?br>Arranges the elements in a specified range into a nondescending order or according to an ordering criterion specified by a binary predicate.

 
template<class RandomAccessIterator>
   void sort(
      RandomAccessIterator _First,
      RandomAccessIterator _Last
   );



Brian 2010-08-17 14:04 鍙戣〃璇勮
]]>
POJ 1001 Exponentiationhttp://www.shnenglu.com/Icho/archive/2010/08/17/123712.htmlBrianBrianTue, 17 Aug 2010 06:02:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123712.htmlhttp://www.shnenglu.com/Icho/comments/123712.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123712.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123712.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123712.html鍒嗙被寮綃囪: 絎竴涓▼搴忔悶浜嗗ソ鍑犲ぉ錛屽彂鐜頒簡寰堝闂銆侾OJ涓嶄繚璇佹寜欏哄簭鍋氫笖鏇存柊閫熷害鑲畾涓嶄細寰堝揩銆傛湁浜涢鑷繁鍋氫笉鍑烘潵鍊熼壌鍒漢鐨勪細娉ㄦ槑鍑哄銆傚緢澶氱畻娉曢兘闇瑕佷粠緗戜笂鎵撅紝絎竴棰樼殑澶ф誕鐐規暟鐩鎬箻鐨勬牳蹇冪畻娉曞氨鏄繖鏍鋒壘鏉ョ殑銆傛垜蹇冮噷鏄庣櫧錛岃櫧鐒禔C浜嗭紝浣嗘槸杈圭紭鏁版嵁澶勭悊鐨勫緢綺楃硻錛屾垜鑷繁閮藉彂鐜板嚑涓猙ug浜嗭紝浣嗘槸渚濈劧AC浜嗐?/p>

鏈涓昏娉ㄦ剰灝嗗瓧絎︿覆杞寲涓哄疄闄呯殑鏁板瓧鐒跺悗鍊熼壌鏁板埗鐨勬濇兂鏉ヨ繘琛屽ぇ鏁扮浉涔樸?/p>

Description

Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems.

This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.

Input

The input will consist of a set of pairs of values for R and n. The R value will occupy columns 1 through 6, and the n value will be in columns 8 and 9.

Output

The output will consist of one line for each line of input giving the exact value of R^n. Leading zeros should be suppressed in the output. Insignificant trailing zeros must not be printed. Don't print the decimal point if the result is an integer.

Sample Input

95.123 12
0.4321 20
5.1234 15
6.7592  9
98.999 10
1.0100 12

Sample Output

548815620517731830194541.899025343415715973535967221869852721
.00000005148554641076956121994511276767154838481760200726351203835429763013462401
43992025569.928573701266488041146654993318703707511666295476720493953024
29448126.764121021618164430206909037173276672
90429072743629540498.107596019456651774561044010001
1.126825030131969720661201
緙栬瘧鍣–++ 婧愮爜:
#include <iostream>
#include <string>
using namespace std;
#define MAX 255
 
int getnum(string s,int *c) // get real number of R
{
    int i=0,j=0,t[MAX];
    memset(t,0,sizeof(int)*MAX); // a stores 0
   
 while (i < 6) // R value 1 through 6
 {
  if (s[i] != '.')
  {
   t[j]=s[i]-'0';
   j++;
  }   
  i++;
 }     // a`s length = 5
   
 for (j=0; j<5; j++)
  c[j]=t[4-j]; // c stores in order from a
  
 for (i=0; s[i] != '.'; i++); // find decimal point
 return (5-i); // the position of . point
}
 
void multi(int *a,int *b) // big-multiplication
{
    int i=0,j,r=0,t[MAX];
    memset(t,0,sizeof(int)*MAX); // t stores 0
   
 for (; i<5; i++)
  for (j=0; j<255; j++)
   t[i+j] += a[i]*b[j]; // core algorithms!
 
 for (i=0; i<255; i++)
 {
  b[i]=(r+t[i])%10; // r always stores remainder
  r=(r+t[i])/10;   // b stores the result
 }    
}    // basic algorithms of b-m
int main() 
{
    int i,j,d_pos,n,a[MAX],b[MAX];
    string s;
    while (cin>>s>>n)
 {
  
  memset(b,0,sizeof(int)*MAX);
  memset(a,0,sizeof(int)*MAX);
  d_pos=getnum(s,a);
  getnum(s,b);
  
  for (i=0; i<n-1; i++)
   multi(a,b);  // a is a loop invariant
  
  for (i=254; !b[i]; i--); //find last non-zero  
  for (j=0; !b[j]; j++); // find first non-zero
  
  for (; i >= n*d_pos; i--) // loop n times
   cout<<b[i];
  if (n*d_pos >= j+1) cout<<"."; //pay attention
  for (i=n*d_pos-1; i>=j; i--)
   cout<<b[i];  //from back formating output
  
  cout<<endl;
 }
 return 0;
}


Brian 2010-08-17 14:02 鍙戣〃璇勮
]]>
POJ 2379 闇囨捈鐨勬墦琛?!!!!!http://www.shnenglu.com/Icho/archive/2010/08/17/123708.htmlBrianBrianTue, 17 Aug 2010 05:55:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123708.htmlhttp://www.shnenglu.com/Icho/comments/123708.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123708.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123708.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123708.html榪欎笉鏄В棰樻姤鍛婏紝鍙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1,1,1,0,0,0,1,0,0,2,0,2,1,2,0,0,2,0,0,1,0,1,1,0,1,0,0,0,0,2,1,1,0,0,0,0,0,0,0,0,1,1,2,0,1,0,2,1,1,2,0,1,
2,1,0,0,0,1,0,1,0,0,0,0,0,1,0,2,1,0,1,1,0,1,0,0,0,1,3,0,0,0,0,0,1,2,0,0,1,1,1,1,0,0,0,1,1,0,0,1,3,1,1,1,0,0,1,1,0,1,0,0,1,1,0,0,0,1,2,1,2,2,0,0,0,2,1,0,0,1,0,1,0,1,0,0,1,2,0,2,0,0,0,1,1,0,0,0,1,1,0,0,
2,0,0,1,1,1,0,0,1,2,1,1,1,1,1,0,0,1,0,0,0,0,0,0,1,0,3,1,1,3,1,0,1,1,0,1,0,1,1,3,0,1,0,0,1,1,1,0,0,1,2,1,2,1,1,0,0,1,2,2,0,0,0,1,1,2,1,0,1,1,1,2,1,0,0,0,1,0,0,1,2,0,0,2,0,0,0,2,0,1,0,0,0,0,1,0,0,0,0,1,
0,2,0,0,0,1,0,3,1,0,1,0,2,0,1,2,0,0,0,0,2,1,1,1,2,0,0,0,0,2,0,1,0,0,0,1,1,1,0,1,0,1,1,0,0,0,0,0,3,2,0,0,0,1,0,2,0,1,1,1,1,0,0,0,1,0,0,1,2,0,2,2,0,1,1,0,1,0,1,1,1,0,0,2,1,0,1,0,1,0,0,0,1,0,1,0,0,0,0,1,
0};
       
int main()
{   
    int n;
    while(scanf("%d",&n),n)
    {
        printf("%d\n",a[n]);   
    }     
}



Brian 2010-08-17 13:55 鍙戣〃璇勮
]]>
POJ 1012 2244 Joseph 闂璇﹁Вhttp://www.shnenglu.com/Icho/archive/2010/08/17/123701.htmlBrianBrianTue, 17 Aug 2010 05:42:00 GMThttp://www.shnenglu.com/Icho/archive/2010/08/17/123701.htmlhttp://www.shnenglu.com/Icho/comments/123701.htmlhttp://www.shnenglu.com/Icho/archive/2010/08/17/123701.html#Feedback0http://www.shnenglu.com/Icho/comments/commentRss/123701.htmlhttp://www.shnenglu.com/Icho/services/trackbacks/123701.html綰︾憻澶幆瀹炲湪鏄お濂囧鍟︼紙鎴戝緢楂樺叴鎴戠殑榪欑瘒鍘熷垱鏂囩珷琚笉灝戜漢杞澆浜嗭紝铏界劧浠栦滑閮芥病鏈夊紩鐢ㄥ嚭澶?.. ...錛夛紒
1012 Joseph
Description

The Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give us the message about the incident. For example when n = 6 and m = 5 then the people will be executed in the order 5, 4, 6, 2, 3 and 1 will be saved.

Suppose that there are k good guys and k bad guys. In the circle the first k are good guys and the last k bad guys. You have to determine such minimal m that all the bad guys will be executed before the first good guy.

Input

The input file consists of separate lines containing k. The last line in the input file contains 0. You can suppose that 0 < k < 14.

Output

The output file will consist of separate lines containing m corresponding to k in the input file.
2244 Eeny Meeny Moo

Description

Surely you have made the experience that when too many people use the Internet simultaneously, the net becomes very, very slow.
To put an end to this problem, the University of Ulm has developed a contingency scheme for times of peak load to cut off net access for some cities of the country in a systematic, totally fair manner. Germany's cities were enumerated randomly from 1 to n. Freiburg was number 1, Ulm was number 2, Karlsruhe was number 3, and so on in a purely random order.
Then a number m would be picked at random, and Internet access would first be cut off in city 1 (clearly the fairest starting point) and then in every mth city after that, wrapping around to 1 after n, and ignoring cities already cut off. For example, if n=17 and m=5, net access would be cut off to the cities in the order [1,6,11,16,5,12,2,9,17,10,4,15,14,3,8,13,7]. The problem is that it is clearly fairest to cut off Ulm last (after all, this is where the best programmers come from), so for a given n, the random number m needs to be carefully chosen so that city 2 is the last city selected.

Your job is to write a program that will read in a number of cities n and then determine the smallest integer m that will ensure that Ulm can surf the net while the rest of the country is cut off.

Input

The input will contain one or more lines, each line containing one integer n with 3 <= n < 150, representing the number of cities in the country.
Input is terminated by a value of zero (0) for n.

Output

For each line of the input, print one line containing the integer m fulfilling the requirement specified above.
 
1012鎵撹〃鍋氭硶 C :
#include<stdio.h>
int a[14]={2,7,5,30,169,441,1872,7632,1740,93313,459901,1358657,2504881,13482720};
int main()
{
 int i;
 while ( scanf("%d",&i), i != 0 )
  printf("%d\n",a[i-1]);
 return 0;
} // 榪欐槸浠庣綉涓婃壘鐨勫仛娉曪紝鍙風О鎵撹〃娉曪紝榪欎簺鏁版嵁渚濇棫瑕侀氳繃寤虹珛寰幆閾捐〃鎴栨槸鍒殑妯℃嫙娉曟潵姹傚嚭銆備絾鏄崟綰負浜咥C錛岃繖縐嶅仛娉曠湡鐨勬槸鐩稿綋鏈夋晥錛岃鐧戒簡灝辨槸鏈夌洰鐨勭殑絀蜂婦緇撴灉銆?/div>
1012妯℃嫙娉?C: 鍙儨鍛鍙儨錛佽繖涓繪槸 瓚呮椂錛佹垜涓嶇煡閬撴槸浠涔堝師鍥犮備絾鏄濊礬鏄紜殑錛屽彲鑳芥湁浜涘湴鏂規垜娌℃湁鑰冭檻鍒幫紝鐪嬪埌榪欑瘒鏃ュ織鐨勪漢璇鋒寚鐐廣?br>
#include<stdio.h>
int main()
{
 int i,m,k,cur,rest;
 
 while(1)
 {
  i=0; // the use ... sort of m in the question
  m=0;
  scanf("%d",&k);
  if (k == 0) break;
  while (1)
  {
   i++;
   rest=2*k; // good + bad guys
   cur=0;
   while (1)
   {
    cur=(cur+i-1)%rest; // find next from ZERO!
    if (cur >= k)
     rest--;
    else break;
   }
   if (rest == k)
   {
    m=i;
    break;
   }
  }
  printf("%d\n",m);
 }
 return 0;
}
瀵逛簬 2244錛屽緩璁湅涓涓墰浜虹殑ACM鍗氬: www.shnenglu.com/AClayton/archive/2007/11/06/35964.html
鎴戝氨鏄湅榪欑瘒鍗氭枃鐨勶紝寰堢墰鐨勪竴涓漢 AClayton 錛屽啓鐨勬棩鏈熷垰濂芥槸鎴戠敓鏃ワ紝涓嬮潰鏄叾鍏ㄩ儴鍗氭枃:
--------------------------------------------------------------------------------------------------------------------------------------------

 鍦ㄦ病鏈夋槑鐧界害鐟熷か闂涔嬪墠,鍙兘鐢ㄦā鎷熸潵鍋?
      綰︾憻澶棶棰樻槸榪欐牱鐨?
      鍋囪n涓漢,緙栧彿涓?鍒皀,鎺掓垚涓涓湀,欏烘椂閽堜粠1寮濮嬫暟瀛梞,鏁板埌m鐨勪漢鏉浜?鍓╀笅鐨勪漢緇х畫娓告垙.媧誨埌鏈鍚庣殑涓涓漢鏄儨鍒╄?涓鑸潵璇撮渶瑕佺紪紼嬫眰瑙f渶鍚庝竴涓漢鐨勭紪鍙?
      鎬濊礬鏄繖鏍風殑:
     鍋囪褰撳墠鍓╀笅i涓漢(i<=n),鏄劇劧榪欎竴杞甿瑕佹寕(鍥犱負鎬繪槸浠?寮濮嬫暟).緇忚繃榪欎竴杞?鍓╀笅鐨勪漢鏄?1 2 3 ... m- 1 m + 1 ... i, 鎴戜滑灝嗕粠m+1寮濮嬬殑鏁版槧灝勬垚1錛?鍒檓+2瀵瑰簲2錛?n瀵瑰簲i - m錛?1瀵瑰簲鎴恑 - m + 1  m - 1瀵瑰簲i - 1錛岄偅涔堢幇鍦ㄧ殑闂鍙樻垚浜嗗凡鐭 - 1涓漢榪涜寰幆鎶ユ暟m錛屾眰鍑哄幓鐨勪漢鐨勫簭鍙楓?/font>鍋囪宸茬粡姹傚嚭浜唅- 1涓漢寰幆鎶ユ暟涓嬫渶鍚庝竴涓嚭鍘葷殑浜虹殑搴忓彿X0錛岄偅涔堝畠鍦╪涓漢涓殑搴忓彿X1=(X0+ m - 1) % n + 1,  鏈鍒濈殑X0=1 ,鍙嶅榪唬X0鍜孹1鍙互姹傚嚭.
     綆鍗曠害鐟熷か闂鐨勮В娉?
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse#include <stdio.h >
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehousemain()
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian WarehousePOJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse{
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
int n, m,i, s=0
;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    printf( 
"N  M  =  "); scanf("%d%d ",&n,&
m);
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
for(i=2;i<=n;i++)s=(s+m)%
i;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    printf(
"The winner is %d\n ", s+1
);
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse}
  

      榪欏掗鍏跺疄涓嶆槸瀹屽叏鐨勭害鐟熷か闂,鑰屾槸紼嶅井鍙樹簡褰?鍛靛懙,鑱槑鐨勮鑰呰嚜宸卞彂鐜?榪欎竴鐐硅垂浜嗘垜寰堜箙鐨勬椂闂?榪樺鎴戦冧簡璇捐鐐瑰悕...
    榪欓亾棰樼殑鎴戣В娉曟槸榪欐牱鐨?

POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse#include   <stdio.h >
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
int y(int n,int m)
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian WarehousePOJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
{
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
int s=1
,i;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
for(i=2;i<=n-1;i++
)
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse        s
=(s+m-1)%i+1
;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
return s+1
;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse}

POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehousemain()
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian WarehousePOJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse{
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
int
 m,n;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
while(1
)
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian WarehousePOJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
{
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    scanf(
"%d",&
n);
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
if(n==0)break
;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse     
for(m=1
;;)
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian WarehousePOJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse     
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
{
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse         
if(y(n,m)==2)break
;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse         m
++
;
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse     }

POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse   
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    printf(
"%d\n",m);
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    
POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse    }

POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse}

POJ 1012 2244 Joseph 闂璇﹁В - Icho - Brian Warehouse

       璇諱竴涓暟澶勭悊涓涓暟, Memory 68K,鏃墮棿31MS,濡傛灉瑙夊緱鏁堢巼涓嶉珮. 浼樺寲鐨勫姙娉曟槸鎵撹〃~

-----------------------------------------------------------------------------------------------------------------------------
鐢辨鍙錛屽皢闂鍖栧綊涓烘暟瀛﹂棶棰橈紝鐢ㄥ垵絳夐珮絳夋垨鏄暟璁烘潵瑙e喅鐨勮兘鍔涙槸澶氫箞閲嶈銆?/strong>
涓嬮潰鏄垜鏍規嵁AClayton鐨勬濊礬綆鍖栧悗鐨勪唬鐮侊紝鍙洿鎺C: 娉ㄦ剰錛?/strong>棰樼洰璁╀綘鍏堣City 1 鎸傛帀
2244  緙栬瘧鍣?C :
#include<stdio.h>
void main()
{
 
int i,r,m,n;
 
while (scanf("%d",&n) && n)
 {
    
for (m=1; ; m++)
    {
     
for (r=1,i=2; i<=n-1; i++)
      r
=(r+m-1)%+ 1;
     
if(r==1break;
    }
    printf(
"%d\n",m);
 }
// 164K  16MS
 


Brian 2010-08-17 13:42 鍙戣〃璇勮
]]> 久久精品黄AA片一区二区三区| 伊人久久大香线蕉综合影院首页| jizzjizz国产精品久久| 久久精品国产福利国产秒| 色综合合久久天天综合绕视看| 国产福利电影一区二区三区,免费久久久久久久精| 97久久精品人人澡人人爽| 国产精品成人久久久| 精品熟女少妇av免费久久| 久久综合成人网| 三上悠亚久久精品| 久久激情亚洲精品无码?V| 精品久久久久久中文字幕大豆网| 久久精品国产99国产精偷| 国产69精品久久久久观看软件| 久久精品国产亚洲网站| 久久精品日日躁夜夜躁欧美| 777久久精品一区二区三区无码| 久久综合视频网| 久久播电影网| 国产亚洲美女精品久久久| 国产精品一久久香蕉产线看| 午夜视频久久久久一区| 精品乱码久久久久久夜夜嗨 | 国产福利电影一区二区三区久久老子无码午夜伦不 | 伊人久久大香线焦综合四虎| 伊人久久大香线蕉综合网站| 成人a毛片久久免费播放| 精品久久久久香蕉网| 亚洲国产欧洲综合997久久| 久久精品成人一区二区三区| 久久er国产精品免费观看2| 久久久久无码精品国产不卡| 欧美精品国产综合久久| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 久久综合给合久久国产免费| 久久只有这里有精品4| 久久精品国产99国产精品亚洲| 久久久国产视频| 午夜精品久久久久久久久| 亚洲va久久久噜噜噜久久狠狠 |