锘??xml version="1.0" encoding="utf-8" standalone="yes"?> MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿 棰樼洰鍦板潃: http://acm.hdu.edu.cn/showproblem.php?pid=1253 棰樼洰鎻忚堪: 棰樼洰鍒嗘瀽: 浠g爜濡備笅: /* MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿 http://www.cnblog.com/MiYu Author By : MiYu Test : 1 Program : HDU1253 */ #include <iostream> #include <queue> using namespace std; int TLE[56][56][56]; const int d[6][3] = { { 0,0,1 },{ 0,0,-1 },{ 0,-1,0 },{ 0,1,0 },{ 1,0,0 },{ -1,0,0 } }; int A, B, C, T, m; typedef struct pos{ pos(){ x=y=z=n=0; } void setPos ( int a,int b,int c, int count ){ x=a;y=b;z=c;n=count; } bool isEnd () { if ( x==1&&y==1&&z==1 )return true;return false; } int x,y,z; int n; }pos; pos t,p; #define CMP(A,B) (A.n < B.n) typedef class Heap { public: pos h[70000 * 2]; int n, p, c; Heap() { n = 0; } void inline push(pos e) { for (p = ++n; p > 1 && CMP(e,h[p>>1]); h[p] = h[p>>1], p >>= 1) ; h[p] = e; } int inline pop(pos &e) { if (!n) return 0; for (e = h[p = 1], c = 2; c < n && CMP(h[c += (CMP(h[c + 1],h[c]) && c < n - 1)], h[n]); h[p] = h[c], p = c, c <<= 1) ; h[p] = h[n--]; return 1; } }Heap; Heap WA; int RE () { if ( A+B+C-2 > T || TLE[A][B][C] == 0 ) return -1; t.setPos ( A,B,C,0 ); TLE[A][B][C] = 0; WA.push ( t ); while ( WA.pop(t) ){ if ( t.x+t.y+t.z-2 > T-t.n ) continue; if ( t.isEnd() ) return t.n; for ( int i = 0; i != 6; ++ i ){ int x = t.x+d[i][0], y=t.y+d[i][1], z=t.z+d[i][2]; if ( TLE[ x ][ y ][ z ] != 0 ){ TLE[ x ][ y ][ z ] = 0; p.setPos ( x, y, z, t.n+1 ); if ( p.isEnd() && p.n <= T ) return p.n; if ( p.n <= T ) WA.push ( p ); } } } return -1; } inline bool scan_d(int &num) { char in;bool IsN=false; in=getchar(); if(in==EOF) return false; while(in!='-'&&(in<'0'||in>'9')) in=getchar(); if(in=='-'){ IsN=true;num=0;} else num=in-'0'; while(in=getchar(),in>='0'&&in<='9'){ num*=10,num+=in-'0'; } if(IsN) num=-num; return true; } int main () { int K; scan_d(K); while ( K -- ){ while ( WA.pop(p) ) ; memset ( TLE, 0 , sizeof ( TLE ) ); scan_d(A); scan_d(B); scan_d(C); scan_d(T); for ( int i = 1; i <= A; ++ i ){ for ( int j = 1; j <= B; ++ j ){ for ( int k = 1; k <= C; ++ k ){ scan_d(m); TLE[i][j][k] = m == 1 ? 0 : 1; } } } TLE[1][1][1] = 1; cout << RE () << endl; } //system( "pause" ); return 0; } MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿 棰樼洰鍦板潃: http://acm.hdu.edu.cn/showproblem.php?pid=1181 棰樼洰鎻忚堪: 棰樼洰鍒嗘瀽: MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?a >
鑳滃埄澶ч冧骸
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4785 Accepted Submission(s): 1454
欖旂帇浣忓湪涓涓煄鍫¢噷,鍩庡牎鏄竴涓狝*B*C鐨勭珛鏂逛綋,鍙互琚〃紺烘垚A涓狟*C鐨勭煩闃?鍒氬紑濮婭gnatius琚叧鍦?0,0,0)鐨勪綅緗?紱誨紑鍩庡牎鐨勯棬鍦?A-1,B-1,C-1)鐨勪綅緗?鐜板湪鐭ラ亾欖旂帇灝嗗湪T鍒嗛挓鍚庡洖鍒板煄鍫?Ignatius姣忓垎閽熻兘浠庝竴涓潗鏍囪蛋鍒扮浉閭葷殑鍏釜鍧愭爣涓殑鍏朵腑涓涓?鐜板湪緇欎綘鍩庡牎鐨勫湴鍥?璇蜂綘璁$畻鍑篒gnatius鑳藉惁鍦ㄩ瓟鐜嬪洖鏉ュ墠紱誨紑鍩庡牎(鍙璧板埌鍑哄彛灝辯畻紱誨紑鍩庡牎,濡傛灉璧板埌鍑哄彛鐨勬椂鍊欓瓟鐜嬪垰濂藉洖鏉ヤ篃綆楅冧骸鎴愬姛),濡傛灉鍙互璇瘋緭鍑洪渶瑕佸灝戝垎閽熸墠鑳界寮,濡傛灉涓嶈兘鍒欒緭鍑?1.
鐗瑰埆娉ㄦ剰:鏈鐨勬祴璇曟暟鎹潪甯稿ぇ,璇蜂嬌鐢╯canf杈撳叆,鎴戜笉鑳戒繚璇佷嬌鐢╟in鑳戒笉瓚呮椂.鍦ㄦ湰OJ涓婅浣跨敤Visual C++鎻愪氦.
榪欓鍜?浜岀淮鐭╅樀鐨勪笉鍚岀偣灝辨槸鏈?涓柟鍚? 鍓嶅悗宸﹀彸涓婁笅. 鐒跺悗涓鐩碆FS灝卞彲浠ヤ簡,涓嶉渶瑕佸壀鏋濋兘鑳借繃...........
]]>
浠g爜
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 2655 Accepted Submission(s): 863
Problem Description
鍛?.....鍙樺艦璇句笂Harry紕板埌浜嗕竴鐐瑰皬楹葷儲,鍥犱負浠栧茍涓嶅儚Hermione閭f牱鑳藉璁頒綇鎵鏈夌殑鍜掕鑰岄殢鎰忕殑灝嗕竴涓鐞冨彉鎴愬埡鐚粈涔堢殑,浣嗘槸浠栧彂鐜頒簡鍙樺艦鍜掕鐨勪竴涓粺涓瑙勫緥:濡傛灉鍜掕鏄互a寮澶碽緇撳熬鐨勪竴涓崟璇?閭d箞瀹冪殑浣滅敤灝辨伆濂芥槸浣緼鐗╀綋鍙樻垚B鐗╀綋.
Harry宸茬粡灝嗕粬鎵浼氱殑鎵鏈夊拻璇兘鍒楁垚浜嗕竴涓〃,浠栨兂璁╀綘甯繖璁$畻涓涓嬩粬鏄惁鑳藉畬鎴愯佸笀鐨勪綔涓?灝嗕竴涓狟(ball)鍙樻垚涓涓狹(Mouse),浣犵煡閬?濡傛灉浠栬嚜宸變笉鑳藉畬鎴愮殑璇?浠栧氨鍙ソ鍚慔ermione璇鋒暀,騫朵笖琚揩鍚竴澶у爢濂藉ソ瀛︿範鐨勯亾鐞?
Input
嫻嬭瘯鏁版嵁鏈夊緇勩傛瘡緇勬湁澶氳錛屾瘡琛屼竴涓崟璇?浠呭寘鎷皬鍐欏瓧姣?鏄疕arry鎵浼氱殑鎵鏈夊拻璇?鏁板瓧0琛ㄧず涓緇勮緭鍏ョ粨鏉?
Output
濡傛灉Harry鍙互瀹屾垚浠栫殑浣滀笟,灝辮緭鍑?/span>"Yes.",鍚﹀垯灝辮緭鍑?/span>"No."(涓嶈蹇界暐浜嗗彞鍙?
Sample Input
so
soon
river
goes
them
got
moon
begin
big
0
Sample Output
Yes.
浠g爜
MiYu鍘熷垱, 杞笘璇鋒敞鏄?nbsp;: 杞澆鑷?nbsp;______________鐧界櫧銇眿
http://m.shnenglu.com/MiYu
Author By : MiYu
Test :
Program :
*/
#include<iostream>
#include<string>
using namespace std;
struct{
char beg;
char end;
}M[101];
bool hash[101],f;
int N;
bool DFS ( char ch )
{
if ( f )
return true;
if( ch == 'm' )
{
f = true;
return true;
}
for ( int i = 0; i < N; ++ i )
if ( M[i].beg == ch && !hash[i] )
{
hash[i] = true;
DFS ( M[i].end );
hash[i] = false;
}
return false;
}
int main ()
{
string str;
while ( cin >> str )
{
N = 0;
f = false;
memset ( hash, 0 , sizeof ( hash ) );
while ( str != "0" )
{
M[N].beg = str[0];
M[N].end = str[ str.size() - 1 ];
N++;
cin >> str;
}
DFS ( 'b' );
puts ( f ? "Yes." : "No." );
}
return 0;
}
浠g爜
鍏蜂綋鎯呭喌鐪嬩唬鐮?
#include<iostream>
using namespace std;
char ss[10];
int main(){
int flag=1;
while(gets(ss)){
if (strcmp(ss,"0")==0){
if (flag){
printf("Yes.\n");
flag=0;
}
else
printf("No.\n");
}
}
return 0;
}
______________鐧界櫧銇眿
]]>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
Note: the number of first circle should always be 1.

You are to write a program that completes above process.
Print a blank line after each case.
]]>
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=1969
棰樼洰鎻忚堪:
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 229 Accepted Submission(s): 65
Problem Description
My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece of one pie, not several small pieces since that looks messy. This piece can be one whole pie though.
My friends are very annoying and if one of them gets a bigger piece than the others, they start complaining. Therefore all of them should get equally sized (but not necessarily equally shaped) pieces, even if this leads to some pie getting spoiled (which is better than spoiling the party). Of course, I want a piece of pie for myself too, and that piece should also be of the same size.
What is the largest possible piece size all of us can get? All the pies are cylindrical in shape and they all have the same height 1, but the radii of the pies can be different.
Input
One line with a positive integer: the number of test cases. Then for each test case:
---One line with two integers N and F with 1 <= N, F <= 10 000: the number of pies and the number of friends.
---One line with N integers ri with 1 <= ri <= 10 000: the radii of the pies.
Output
For each test case, output one line with the largest possible volume V such that me and my friends can all get a pie piece of size V. The answer should be given as a floating point number with an absolute error of at most 10^(-3).
Sample Input
3
3 3
4 3 3
1 24
5
10 5
1 4 2 3 4 5 6 5 4 2
Sample Output
25.1327
3.1416
50.2655
棰樼洰鍒嗘瀽:
棰樼洰澶ф剰鏄鍔炵敓鏃arty錛屾湁n涓楗鹼紝鏈塮涓湅鍙嬶紝鎺ヤ笅鏉ユ槸n涓楗肩殑鍗婂緞銆傜劧鍚庢槸鍒嗛楗間簡錛?br>娉ㄦ剰鍜嚜宸變篃瑕侊紝澶у閮借涓鏍峰ぇ錛屽艦鐘舵病浠涔堣姹傦紝浣嗛兘瑕佹槸涓鏁村潡鐨勯偅縐嶏紝涔熷氨鏄涓嶈兘浠庝袱涓ゼ涓?br>鍚勫壊涓灝忓潡鏉ュ噾涓鍧楋紝鍍忛潰縐負10鐨勫拰6鐨勪袱鍧楅ゼ錛堥ゼ鐨勫帤搴︽槸1錛屾墍浠ラ潰縐拰浣撶Н鐩哥瓑錛夛紝
濡傛灉姣忎漢鍒嗗埌闈㈢Н涓?錛屽垯10鍒嗕袱鍧楋紝6鍒囨垚5錛屽鍒?涓漢錛屽鏋滄瘡浜?錛屽垯鍙兘鍒嗕袱涓簡錛?br>棰樼洰瑕佹眰鎴戜滑鍒嗗埌鐨勯ゼ灝藉彲鑳界殑澶э紒
鍙娉ㄦ剰綺懼害闂灝卞彲浠ヤ簡,涓鑸琖A 閮芥槸綺懼害闂.
浠g爜濡備笅:
#include <cmath>
using namespace std;
double a[10005];
int N,f;
double pi = acos ( -1.0 );
bool test ( double x )
{
int count = 0;
for ( int i = 1; i <= N; ++ i )
{
count += int ( a[i] / x );
}
if ( count >= f + 1 )
{
return true;
}
else
{
return false;
}
}
int main()
{
int T;
scanf ( "%d", &T );
while ( T -- )
{
double sum = 0;
double rad;
scanf("%d%d",&N,&f);
for ( int i = 1; i <= N; ++ i )
{
scanf ( "%lf", &rad );
a[i] = rad * rad * pi;
sum += a[i];
}
double max = sum / ( f + 1 );
double l = 0.0;
double r = max;
double mid = 0.0;
while ( r - l > 1e-6 )
{
mid = ( l + r ) / 2;
if ( test ( mid ) )
{
l = mid;
}
else
{
r = mid;
}
}
printf("%.4lf\n",mid);
}
return 0;
}
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=2899
棰樼洰鎻忚堪:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 95 Accepted Submission(s): 75
Problem Description
Now, here is a fuction:
F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
Can you find the minimum value when x is between 0 and 100.
Input
The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has only one real numbers Y.(0 < Y <1e10)
Output
Just the minimum value (accurate up to 4 decimal places),when x is between 0 and 100.
Sample Input
2
100
200
Sample Output
-74.4291
-178.8534
棰樼洰鍒嗘瀽:
鍒嗘瀽鍑烘潵浣跨敤2鍒嗘悳绱㈠氨鍙互浜?.........
浠g爜濡備笅:
#include <cmath>
using namespace std;
#define POW(x) ( (x) * (x) )
#define POW3(x) ( POW(x) * (x) )
MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿
#define POW4(x) ( POW(x) * POW(x) )
double y = 0;
double cal ( double n )
{
return 8.0 * POW4(n) + 7 * POW3(n) + 2 * POW(n) + 3 * n + 6 ;
}
int main ()
{
int T;
scanf ( "%d",&T );
while ( T -- )
{
scanf ( "%lf",&y );
if ( cal(0) > y || cal(100) < y )
{
printf ( "No solution!\n" );
continue;
}
double l = 0.0, r = 100.0,res = 0.0;
while ( r - l > 1e-6 )
{
double mid = ( l + r ) / 2.0;
res = cal ( mid );
if ( res > y )
r = mid - 1e-6;
else
l = mid + 1e-6;
}
printf ( "%.4lf\n",( l + r ) / 2.0 );
}
return 0;
}
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=2199
棰樼洰鎻忚堪:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 322 Accepted Submission(s): 148
Problem Description
Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100;
Now please try your lucky.
Input
The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has a real number Y (fabs(Y) <= 1e10);
Output
For each test case, you should just output one real number(accurate up to 4 decimal places),which is the solution of the equation,or “No solution!”,if there is no solution for the equation between 0 and 100.
Sample Input
2
100
-4
Sample Output
1.6152
No solution!
棰樼洰鍒嗘瀽:
涓嬮潰鐨勬槸閫掑綊 RE 鐨勪唬鐮?:
#include <iostream>
#include <cmath>
using namespace std;
#define POW(x) ( (x) * (x) )
#define POW3(x) ( POW(x) * (x) )
#define POW4(x) ( POW(x) * POW(x) )
double y = 0;
bool douEql ( double a,double b )
{
if ( fabs( a - b ) <= 1e-6 )
return true;
return false;
}
double cal ( double n )
{
return 8.0 * POW4(n) + 7 * POW3(n) + 2 * POW(n) + 3 * n + 6 ;
}
double biSearch ( double l, double r )
{
if ( douEql ( l,r ) )
{
if ( douEql ( y, cal ( l ) ) )
return l;
return -1;
}
double mid = ( l + r ) / 2.0;
if ( douEql ( y, cal ( mid ) ) )
return mid;
else if ( cal ( mid ) > y )
return biSearch ( l,mid - 0.0001 );
else
return biSearch ( mid + 0.0001, r );
}
int main ()
{
int T;
scanf ( "%d",&T );
while ( T -- )
{
scanf ( "%lf",&y );
if ( cal(0) >= y && cal(100) <= y )
{
printf ( "No solution!\n" );
continue;
}
double res = biSearch ( 0.0, 100.0 );
if ( res == -1 )
printf ( "No solution!\n" );
else
printf ( "%.4lf\n",res );
}
return 0;
}
AC浠g爜濡備笅:
#include <iostream>
#include <cmath>
using namespace std;
#define POW(x) ( (x) * (x) )
#define POW3(x) ( POW(x) * (x) )
#define POW4(x) ( POW(x) * POW(x) )
double y = 0;
double cal ( double n )
{
return 8.0 * POW4(n) + 7 * POW3(n) + 2 * POW(n) + 3 * n + 6 ;
}
int main ()
{
int T;
scanf ( "%d",&T );
while ( T -- )
{
scanf ( "%lf",&y );
if ( cal(0) > y || cal(100) < y )
{
printf ( "No solution!\n" );
continue;
}
double l = 0.0, r = 100.0,res = 0.0;
while ( r - l > 1e-6 )
{
double mid = ( l + r ) / 2.0;
res = cal ( mid );
if ( res > y )
r = mid - 1e-6;
else
l = mid + 1e-6;
}
printf ( "%.4lf\n",( l + r ) / 2.0 );
}
return 0;
}
]]>