Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 495 Accepted Submission(s): 226
Problem Description
Given an N*N*N cube A, whose elements are either 0 or 1. A[i, j, k] means the number in the i-th row , j-th column and k-th layer. Initially we have A[i, j, k] = 0 (1 <= i, j, k <= N). We define two operations, 1: “Not” operation that we change the A[i, j, k]=!A[i, j, k]. that means we change A[i, j, k] from 0->1,or 1->0. (x1<=i<=x2,y1<=j<=y2,z1<=k<=z2). 0: “Query” operation we want to get the value of A[i, j, k].
Input
Multi-cases. First line contains N and M, M lines follow indicating the operation below. Each operation contains an X, the type of operation. 1: “Not” operation and 0: “Query” operation. If X is 1, following x1, y1, z1, x2, y2, z2. If X is 0, following x, y, z.
Output
For each query output A[x, y, z] in one line. (1<=n<=100 sum of m <=10000)
]]>甯哥敤綆楁硶璁茶В---榪唬娉?/title>http://www.shnenglu.com/MiYu/archive/2010/08/27/124963.htmlMiYuMiYuFri, 27 Aug 2010 11:18:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/27/124963.htmlhttp://www.shnenglu.com/MiYu/comments/124963.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/27/124963.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/124963.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/124963.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿
浠g爜
瑕佷嬌璁$畻鏈鴻兘瀹屾垚浜轟滑棰勫畾鐨勫伐浣滐紝棣栧厛蹇呴』涓哄浣曞畬鎴愰瀹氱殑宸ヤ綔璁捐涓涓畻娉曪紝鐒跺悗鍐嶆牴鎹畻娉曠紪鍐欑▼搴忋傝綆楁満紼嬪簭瑕佸闂鐨勬瘡涓璞″拰澶勭悊瑙勫垯緇欏嚭姝g‘璇﹀敖鐨勬弿榪幫紝鍏朵腑紼嬪簭鐨勬暟鎹粨鏋勫拰鍙橀噺鐢ㄦ潵鎻忚堪闂鐨勫璞★紝紼嬪簭緇撴瀯銆佸嚱鏁板拰璇彞鐢ㄦ潵鎻忚堪闂鐨勭畻娉曘傜畻娉曟暟鎹粨鏋勬槸紼嬪簭鐨勪袱涓噸瑕佹柟闈€?br>綆楁硶鏄棶棰樻眰瑙h繃紼嬬殑綺劇‘鎻忚堪錛屼竴涓畻娉曠敱鏈夐檺鏉″彲瀹屽叏鏈烘鍦版墽琛岀殑銆佹湁紜畾緇撴灉鐨勬寚浠ょ粍鎴愩傛寚浠ゆ紜湴鎻忚堪浜?jiǎn)瑕佸畬鎴愮殑鋼Q鍔″拰瀹冧滑琚墽琛岀殑欏哄簭銆傝綆楁満鎸夌畻娉曟寚浠ゆ墍鎻忚堪鐨勯『搴忔墽琛岀畻娉曠殑鎸囦護(hù)鑳藉湪鏈夐檺鐨勬楠ゅ唴緇堟錛屾垨緇堟浜庣粰鍑洪棶棰樼殑瑙o紝鎴栫粓姝簬鎸囧嚭闂瀵規(guī)杈撳叆鏁版嵁鏃犺В銆?br>閫氬父姹傝В涓涓棶棰樺彲鑳戒細(xì)鏈夊縐嶇畻娉曞彲渚涢夋嫨錛岄夋嫨鐨勪富瑕佹爣鍑嗘槸綆楁硶鐨勬紜у拰鍙潬鎬э紝綆鍗曟у拰鏄撶悊瑙fс傚叾嬈℃槸綆楁硶鎵闇瑕佺殑瀛樺偍絀洪棿灝戝拰鎵ц鏇村揩絳夈?br>綆楁硶璁捐鏄竴浠墮潪甯稿洶闅劇殑宸ヤ綔錛岀粡甯擱噰鐢ㄧ殑綆楁硶璁捐鎶鏈富瑕佹湁榪唬娉曘佺┓涓炬悳绱㈡硶銆侀掓帹娉曘佽椽濠硶銆佸洖婧硶銆佸垎娌繪硶銆佸姩鎬佽鍒掓硶絳夌瓑銆傚彟澶栵紝涓轟簡(jiǎn)鏇寸畝媧佺殑褰㈠紡璁捐鍜岃棎瑙嗙畻娉曪紝鍦ㄧ畻娉曡璁℃椂鍙堝父甯擱噰鐢ㄩ掑綊鎶鏈紝鐢ㄩ掑綊鎻忚堪綆楁硶銆?br>涓銆佽凱浠f硶 榪唬娉曟槸鐢ㄤ簬姹傛柟紼嬫垨鏂圭▼緇勮繎浼兼牴鐨勪竴縐嶅父鐢ㄧ殑綆楁硶璁捐鏂規(guī)硶銆傝鏂圭▼涓篺(x)=0錛岀敤鏌愮鏁板鏂規(guī)硶瀵煎嚭絳変環(huán)鐨勫艦寮弜=g(x)錛岀劧鍚庢寜浠ヤ笅姝ラ鎵ц錛?br>錛?/span>1錛?nbsp; 閫変竴涓柟紼嬬殑榪戜技鏍癸紝璧嬬粰鍙橀噺x0錛?br>錛?/span>2錛?nbsp; 灝唜0鐨勫間繚瀛樹簬鍙橀噺x1錛岀劧鍚庤綆梘(x1)錛屽茍灝嗙粨鏋滃瓨浜庡彉閲弜0錛?br>錛?/span>3錛?nbsp; 褰搙0涓巟1鐨勫樊鐨勭粷瀵瑰艱繕灝忎簬鎸囧畾鐨勭簿搴﹁姹傛椂錛岄噸澶嶆楠わ紙2錛夌殑璁$畻銆?br>鑻ユ柟紼嬫湁鏍癸紝騫朵笖鐢ㄤ笂榪版柟娉曡綆楀嚭鏉ョ殑榪戜技鏍瑰簭鍒楁敹鏁涳紝鍒欐寜涓婅堪鏂規(guī)硶姹傚緱鐨剎0灝辮涓烘槸鏂圭▼鐨勬牴銆備笂榪扮畻娉曠敤C紼嬪簭鐨勫艦寮忚〃紺轟負(fù)錛?br>銆愮畻娉曘戣凱浠f硶姹傛柟紼嬬殑鏍?br>{ x0=鍒濆榪戜技鏍癸紱 do { x1=x0錛?br> x0=g(x1)錛?nbsp; /*鎸夌壒瀹氱殑鏂圭▼璁$畻鏂扮殑榪戜技鏍?/span>*/ } while ( fabs(x0-x1)>Epsilon)錛?br> printf(“鏂圭▼鐨勮繎浼兼牴鏄?/span>%f\n”錛寈0)錛?br>} 榪唬綆楁硶涔熷父鐢ㄤ簬姹傛柟紼嬬粍鐨勬牴錛屼護(hù) X=錛坸0錛寈1錛?#8230;錛寈n-1錛?br>璁炬柟紼嬬粍涓猴細(xì) xi=gi(X) (I=0錛?/span>1錛?#8230;錛宯-1) 鍒欐眰鏂圭▼緇勬牴鐨勮凱浠g畻娉曞彲鎻忚堪濡備笅錛?br>銆愮畻娉曘戣凱浠f硶姹傛柟紼嬬粍鐨勬牴 { for (i=0;i<n;i++) x[i]=鍒濆榪戜技鏍? do { for (i=0;i<n;i++) y[i]=x[i]; for (i=0;i<n;i++) x[i]=gi(X); for (delta=0.0,i=0;i<n;i++) if (fabs(y[i]-x[i])>delta) delta=fabs(y[i]-x[i])錛?br> } while (delta>Epsilon)錛?br> for (i=0;i<n;i++) printf(“鍙橀噺x[%d]鐨勮繎浼兼牴鏄?nbsp;%f”錛孖錛寈[i])錛?br> printf(“\n”)錛?br> } 鍏蜂綋浣跨敤榪唬娉曟眰鏍規(guī)椂搴旀敞鎰忎互涓嬩袱縐嶅彲鑳藉彂鐢熺殑鎯呭喌錛?br>錛?/span>1錛?nbsp; 濡傛灉鏂圭▼鏃犺В錛岀畻娉曟眰鍑虹殑榪戜技鏍瑰簭鍒楀氨涓嶄細(xì)鏀舵暃錛岃凱浠h繃紼嬩細(xì)鍙樻垚姝誨驚鐜紝鍥犳鍦ㄤ嬌鐢ㄨ凱浠g畻娉曞墠搴斿厛鑰冨療鏂圭▼鏄惁鏈夎В錛屽茍鍦ㄧ▼搴忎腑瀵硅凱浠g殑嬈℃暟緇欎簣闄愬埗錛?br>錛?/span>2錛?nbsp; 鏂圭▼铏界劧鏈夎В錛屼絾榪唬鍏紡閫夋嫨涓嶅綋錛屾垨榪唬鐨勫垵濮嬭繎浼兼牴閫夋嫨涓嶅悎鐞嗭紝涔熶細(xì)瀵艱嚧榪唬澶辮觸銆?/span>
]]>HDOJ 1016 HDU 1016 Prime Ring Problem ACM 1016 IN HDUhttp://www.shnenglu.com/MiYu/archive/2010/08/18/123815.htmlMiYuMiYuWed, 18 Aug 2010 04:32:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/18/123815.htmlhttp://www.shnenglu.com/MiYu/comments/123815.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/18/123815.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/123815.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/123815.html棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=1016
棰樼洰鎻忚堪:
Prime Ring Problem
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6150 Accepted Submission(s): 2745
Problem Description
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.
Note: the number of first circle should always be 1.
Input
n (0 < n < 20).
Output
The output format is shown as sample below. Each row represents a series of circle numbers in the ring beginning from 1 clockwisely and anticlockwisely. The order of numbers must satisfy the above requirements. Print solutions in lexicographical order.
You are to write a program that completes above process.
Input 杈撳叆鏁版嵁鐨勭涓琛屾槸涓涓暟鎹甌錛岃〃紺烘湁T緇勬暟鎹?br>姣忕粍鏁版嵁鐨勭涓琛屾槸涓や釜鏁存暟n(1<= n <=40)錛宬(1<= k <=8)銆?br>鎺ョ潃鏈塳琛岋紝姣忚鏈変袱涓暣鏁癮(1<= a <=8),b(1<= b <=10)錛岃〃紺哄鍒嗕負(fù)a鐨勮鏈塨闂ㄣ?br>
#include <iostream> usingnamespace std; int score[9]; int amt[9]; int num1[41]; int num2[41]; int main () { int T; while ( cin >> T ) { while ( T -- ) { int N,K; cin >> N >> K; for ( int i =1; i<= K; ++ i ) { cin >> score[i] >> amt[i]; } for ( int i =0; i <= N; ++ i ) { num1[i] = num2[i] =0; } num1[0] =1; for ( int i =1; i <= K; ++ i ) { for ( int j =0; j <= N; ++ j ) { for ( int k =0; k <= amt[i] && k * score[i] + j <= N; ++ k ) { num2[ k * score[i] + j ] += num1[j]; } } for ( int j =0; j <= N; ++ j ) { num1[j] = num2[j]; num2[j] =0; } } cout << num1[N] << endl; } } return0; }
]]>HDOJ HDU 1164 Eddy's research I ACM 1164 IN HDU http://www.shnenglu.com/MiYu/archive/2010/08/06/122398.htmlMiYuMiYuFri, 06 Aug 2010 01:18:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/06/122398.htmlhttp://www.shnenglu.com/MiYu/comments/122398.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/06/122398.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/122398.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/122398.html//MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿
#include <iostream> usingnamespace std; int num[70001]; int main () { for ( int i =2; i <=70000; ++ i ) { if ( !num[i] ) for ( int j =2; i * j <=70000; ++ j ) { num[i*j] =1; } } int N; while ( cin >> N ) { int n = N; int f =1; while ( n !=1 ) { int i =2; for ( ; i <=65535; ++ i ) { if ( !num[i] && n % i ==0 ) { if ( f ) { cout << i; f =0; } else { cout <<"*"<< i; } break; } } n /= i; } cout << endl; } // getchar(); return0; }