锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=1205
棰樼洰鎻忚堪:
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 2000/1000 K (Java/Others)
Total Submission(s): 4426 Accepted Submission(s): 1310
Problem Description
HOHO錛岀粓浜庝粠Speakless鎵嬩笂璧㈣蛋浜嗘墍鏈夌殑緋栨灉錛屾槸Gardon鍚冪硸鏋滄椂鏈変釜鐗規畩鐨勭櫀濂斤紝灝辨槸涓嶅枩嬈㈠皢涓鏍風殑緋栨灉鏀懼湪涓璧峰悆錛屽枩嬈㈠厛鍚冧竴縐嶏紝涓嬩竴嬈″悆鍙︿竴縐嶏紝榪欐牱錛涘彲鏄疓ardon涓嶇煡閬撴槸鍚﹀瓨鍦ㄤ竴縐嶅悆緋栨灉鐨勯『搴忎嬌寰椾粬鑳芥妸鎵鏈夌硸鏋滈兘鍚冨畬錛熻浣犲啓涓▼搴忓府蹇欒綆椾竴涓嬨?br>
Input
絎竴琛屾湁涓涓暣鏁癟錛屾帴涓嬫潵T緇勬暟鎹紝姣忕粍鏁版嵁鍗?琛岋紝絎竴琛屾槸涓涓暣鏁癗錛?/span>0<N<=1000000)錛岀浜岃鏄疦涓暟錛岃〃紺篘縐嶇硸鏋滅殑鏁扮洰Mi(0<Mi<=1000000)銆?br>
Output
瀵逛簬姣忕粍鏁版嵁錛岃緭鍑轟竴琛岋紝鍖呭惈涓涓?/span>"Yes"鎴栬?/span>"No"銆?br>
Sample Input
2
3
4 1 1
5
5 4 3 2 1
Sample Output
No
Yes
棰樼洰鍒嗘瀽 :
浠g爜濡備笅:
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=1235
寰堣皝鐨勯, 鐩存帴 hash 灝卞彲浠ヤ簡.
浠g爜濡備笅 :
#include <map>
using namespace std;
int main ()
{
int N;
while ( scanf ( "%d",&N ) , N )
{
map < int ,int > mp;
int num;
for ( int i = 0; i != N; ++ i )
{
scanf ( "%d",&num );
mp[num] ++;
}
scanf ( "%d",&num );
cout << mp[num] << endl;
}
//getchar();
return 0;
}
{int scr[101],i;while(scanf("%d",&N),N){
memset ( scr , 0, sizeof ( scr ) );
for (i = 0; i != N; ++ i )
{scanf ( "%d",&num );scr[num] ++;}
scanf ("%d",&num);
printf ("%d\n",scr[num]);}
}
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=1201
棰樼洰鎻忚堪:
Gardon鐨?8宀佺敓鏃ュ氨瑕佸埌浜嗭紝浠栧綋鐒跺緢寮蹇冿紝鍙槸浠栫獊鐒舵兂鍒頒竴涓棶棰橈紝鏄笉鏄瘡涓漢浠庡嚭鐢熷紑濮嬶紝鍒拌揪18宀佺敓鏃ユ椂鎵緇忚繃鐨勫ぉ鏁伴兘鏄竴鏍風殑鍛紵浼間箮騫朵笉鍏ㄩ兘鏄繖鏍鳳紝鎵浠ヤ粬鎯寵浣犲府蹇欒綆椾竴涓嬩粬鍜屼粬鐨勫嚑涓湅鍙嬩粠鍑虹敓鍒拌揪18宀佺敓鏃ユ墍緇忚繃鐨勬誨ぉ鏁幫紝璁╀粬濂芥潵姣旇緝涓涓嬨?br>
Input
涓涓暟T錛屽悗闈琛屾瘡琛屾湁涓涓棩鏈燂紝鏍煎紡鏄痀YYY-MM-DD銆傚鎴戠殑鐢熸棩鏄?988-03-07銆?br>
Output
T琛岋紝姣忚涓涓暟錛岃〃紺烘浜轟粠鍑虹敓鍒?8宀佺敓鏃ユ墍緇忚繃鐨勫ぉ鏁般傚鏋滆繖涓漢娌℃湁18宀佺敓鏃ワ紝灝辮緭鍑?/span>-1銆?br>
Sample Input
1
1988-03-07
Sample Output
6574
姘撮, 娉ㄦ剰鏈夋病鏈?8宀佸拰 鐟炲勾鐨勫垽鏂氨濂戒簡
浠g爜濡備笅 ( 鍙傜収濂嬫枟鍝?) :
#include <cmath>
using namespace std;
bool isLeap ( int n )
{
return !( n % ( n % 100 ? 4 : 400 ) );
}
int main ()
{
int T;
scanf ( "%d", &T );
while ( T -- )
{
int year, month, day;
scanf ( "%d-%d-%d", &year, &month, &day );
if ( month == 2 && day == 29 )
{
cout << -1 << endl;
continue;
}
int run = 0;
if ( month >= 3 )
{
for ( int i = 1; i <= 18; ++ i )
{
if ( isLeap ( year + i ) )
{
run ++;
}
}
}
else
{
for ( int i = 0; i < 18; ++ i )
{
if ( isLeap ( year + i ) )
{
run ++;
}
}
}
cout << 365 * 18 + run << endl;
}
return 0;
}
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=1202
棰樼洰鎻忚堪:
姣忓鏈熺殑鏈熸湯錛屽ぇ瀹墮兘浼氬繖浜庤綆楄嚜宸辯殑騫沖潎鎴愮嘩錛岃繖涓垚緇╁浜庤瘎濂栧閲戞槸鐩存帴鏈夊叧鐨勩傚浗澶栧ぇ瀛﹂兘鏄綆桮PA(grade point average) 鍙堢ОGPR(grade point ratio)錛屽嵆鎴愮嘩鐐規暟涓庡鍒嗙殑鍔犳潈騫沖潎鍊兼潵浠h〃涓涓鐢熺殑鎴愮嘩鐨勩傞偅涔堝浣曟潵璁$畻GPA鍛紵
涓鑸ぇ瀛﹂噰鐢ㄤ箣璁″垎娉?nbsp;
A90 - 100 4 鐐?nbsp;
B80 - 89 3 鐐?nbsp;
C70 - 79 2 鐐?nbsp;
D60 - 69 1 鐐?nbsp;
E0 - 59 0 鐐?nbsp;
渚嬪錛氭煇浣嶅鐢熶慨涔犱笁闂ㄨ錛屽叾璇劇洰銆佸鍒嗗強鎴愮嘩鍒嗗埆涓猴細
鑻辨枃錛氫笁瀛﹀垎銆?/span>92 鍒嗭紱鍖栧錛氫簲瀛﹀垎銆?/span>80 鍒嗭紱鏁板錛氫簩瀛﹀垎銆?0鍒嗭紝鍒橤PA鐨勭畻娉曞涓嬶細
縐戠洰 瀛﹀垎 鍒嗘暟 鐐規暟 鍒嗘暟×鐐規暟
鑻辨枃 3 92 4 12
鍖栧 5 80 3 15
鏁板 2 60 1 2
鍚堣 10 29
29/10=2.9
2.9鍗充負鏌愮敓鐨凣PA
涓嬮潰鏈夎浣犲啓涓涓敤浜庤綆桮PA鐨勭▼搴忋?br>
Input
鍖呭惈澶氱粍鏁版嵁錛屾瘡緇勬暟鎹殑絎竴琛屾湁涓涓暟N錛屾帴涓嬫潵N琛屾瘡琛岃〃紺轟竴闂ㄦ垚緇┿傛瘡琛屾湁涓や釜瀹炲瀷鐨勬暟 s,p錛宻琛ㄧず榪欓棬璇劇殑瀛﹀垎,p琛ㄧず璇ュ鐢熺殑鎴愮嘩錛堢櫨鍒嗗埗錛夈傚鏋減=-1鍒欒鏄庤瀛︾敓榪欓棬璇劇己鑰冿紝鏄笉搴旇璁$畻鍦ㄥ唴鐨勩?br>
Output
瀵規瘡緇勬暟鎹緭鍑轟竴琛岋紝琛ㄧず璇ュ鐢熺殑GPA錛屼繚鐣欎袱浣嶅皬鏁般傚鏋淕PA涓嶅瓨鍦紝杈撳嚭-1銆?br>
Sample Input
3
3 92
5 80
2 60
Sample Output
2.90
姣棤鐤戦棶, 榪欐槸涓涓按棰? 浣嗘槸鎴戞偛鍓х殑榪樻槸WA 浜?嬈?, 娉ㄦ剰鍒伴鐩殑杈撳嚭瑕佹眰閲屾湁涓鍙ヨ瘽 : 濡傛灉 GPA涓嶅瓨鍦?杈撳嚭 -1 .
浠涔堟椂鍊欎笉瀛樺湪? 0 ! 鍙鎶婅繖涓? 澶勭悊濂藉氨琛屼簡. YM .
浠g爜濡備笅 :
#include <iostream>
#include <iomanip>
using namespace std;
int hash[11] = { 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
int main ()
{
int T;
while ( cin >> T )
{
double total = 0 , pnt = 0, scr = 0 , mlt = 0;
while ( T -- )
{
cin >> pnt >> scr;
if ( scr == -1 )
{
continue;
}
total += pnt;
mlt += pnt * hash[ (int)scr / 10 ];
}
if ( total < 1e-5 )
{
cout << -1 << endl;
continue;
}
cout << setprecision (2) << setiosflags ( ios::fixed ) << mlt * 1.0 / total << endl;
}
return 0;
}
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=2061
棰樼洰鎻忚堪:
background:
A new semester comes , and the HDU also meets its 50th birthday. No matter what's your major, the only thing I want to tell you is:"Treasure the college life and seize the time." Most people thought that the college life should be colorful, less presure.But in actual, the college life is also busy and rough. If you want to master the knowledge learned from the book, a great deal of leisure time should be spend on individual study and practise, especially on the latter one. I think the every one of you should take the learning attitude just as you have in senior school.
"No pain, No Gain", HDU also has scholarship, who can win it? That's mainly rely on the GPA(grade-point average) of the student had got. Now, I gonna tell you the rule, and your task is to program to caculate the GPA.
If there are K(K > 0) courses, the i-th course has the credit Ci, your score Si, then the result GPA is
GPA = (C1 * S1 + C2 * S2 +……+Ci * Si……) / (C1 + C2 + ……+ Ci……) (1 <= i <= K, Ci != 0)
If there is a 0 <= Si < 60, The GPA is always not existed.
Input
The first number N indicate that there are N test cases(N <= 50). In each case, there is a number K (the total courses number), then K lines followed, each line would obey the format: Course-Name (Length <= 30) , Credits(<= 10), Score(<= 100).
Notice: There is no blank in the Course Name. All the Inputs are legal
Output
Output the GPA of each case as discribed above, if the GPA is not existed, ouput:"Sorry!", else just output the GPA value which is rounded to the 2 digits after the decimal point. There is a blank line between two test cases.
Sample Input
2
3
Algorithm 3 97
DataStruct 3 90
softwareProject 4 85
2
Database 4 59
English 4 81
Sample Output
90.10
Sorry!
棰樼洰鍒嗘瀽:
榪欏彧鏄竴閬撶畝鍗曠殑鏁板艱綆楅, 鍞竴鐨勯毦搴﹀湪璇婚. 鐩存帴浣跨敤棰樼洰緇欏嚭鐨勫叕寮忓氨鍙互浜? 褰撶劧濡傛灉鎸傜鐨勮瘽,瑕佽緭鍑?"Sorry!"
涓嬮潰鏄鐩殑澶ц嚧緲昏瘧:
鏂扮殑瀛︽湡鍗沖皢鍒版潵錛屼篃姝i㈡澀宸炵數瀛愮鎶澶у50鍛ㄥ勾鏍″簡銆傛棤璁轟綘鐨勪笓涓氭槸浠涔堬紝鎴戝敮涓瑕佸憡璇夐偅涔堢殑鏄細“鐝嶆儨澶у鐨勭敓媧伙紝鍒╃敤濂芥椂闂淬?#8221; 寰堝浜鴻涓哄ぇ瀛︾殑鐢熸椿鍥炴槸涓板瘜澶氶噰銆備絾浜嬪疄鏄紝澶у鐢熸椿涔熷悓鏍峰繖紕屻傚鏋滀綘瑕佹帉鎻′功涓婄殑鐭ヨ瘑錛屼綘鐨勭┖闂叉椂闂村繀欏昏姳鍦ㄨ嚜瀛﹀拰瀹炶返涓婏紝灝ゅ叾鏄疄璺點傛垜璁や負錛屼綔涓轟竴浣嶅ぇ瀛︾敓錛屾墍鏈変漢閮藉繀欏葷姝h嚜宸辯殑瀛︿範鎬佸害銆?br>“娌℃湁涓嶅姵鑰岃幏鐨勪簨鎯?#8221;錛屾澀鐢典篃璁劇珛浜嗗瀛﹂噾錛屼綘鑳藉緱鍒板悧錛熷畠涓昏渚濇嵁鏄鐢熻幏寰楃殑GPA(嫻嬭瘎騫沖潎鍒?銆傜幇鍦紝鎴戝皢鍛婅瘔浣犲畠鐨勮鍒欙紝浣犵殑浠誨姟灝辨槸緙栫▼璁$畻GPA銆?br>鍋囧鏈塊闂ㄨ紼嬶紝絎琲闂ㄨ鐨勫鍒嗕負Ci錛屼綘鐨勬垚緇╀負涓篠i錛屽垯GPA涓猴細
GPA = (C1 * S1 + C2 * S2 +……+Ci * Si……) / (C1 + C2 + ……+ Ci……) (1 <= i <= K, Ci != 0)
濡傛灉鏈変竴闂ㄨ紼嬫垚緇╁湪0鍒?0涔嬮棿錛屽垯GPA灝嗕笉瀛樺湪銆?/span>
浠g爜濡備笅:
#include <iostream>
int main ()
{
int f, T, N;
double s, c;
double up, down;
scanf( "%d", &T );
while ( T -- )
{
scanf ( "%d", &N );
up = down = f = 0;
while ( N -- )
{
scanf ( "%*s%lf%lf", &c, &s );
if ( f )
{
continue;
}
if ( s < 60 && s >= 0 )
{
f = 1;
}
up += s * c;
down += c;
}
printf( f ? "Sorry!\n" : "%.2f\n", up / down );
if ( T ) putchar ( '\n' );
}
return 0;
}
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=2088
棰樼洰鎻忚堪:
Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. “Look, I've built a wall!”, he tells his older sister Alice. “Nah, you should make all stacks the same height. Then you would have a real wall.”, she retorts. After a little consideration, Bob sees that she is right. So he sets out to rearrange the bricks, one by one, such that all stacks are the same height afterwards. But since Bob is lazy he wants to do this with the minimum number of bricks moved. Can you help?
Input
The input consists of several data sets. Each set begins with a line containing the number n of stacks Bob has built. The next line contains n numbers, the heights hi of the n stacks. You may assume 1≤n≤50 and 1≤hi≤100.
The total number of bricks will be divisible by the number of stacks. Thus, it is always possible to rearrange the bricks such that all stacks have the same height.
The input is terminated by a set starting with n = 0. This set should not be processed.
Output
For each set, print the minimum number of bricks that have to be moved in order to make all the stacks the same height.
Output a blank line between each set.
Sample Input
6
5 2 4 1 7 5
0
Sample Output
5
棰樼洰鍒嗘瀽:
鍝堝搱 ,鍙堟槸涓涓按棰? 璨屼技榪欐鏃墮棿涓鐩村湪姘撮. 鍒氬紑濮嬬湅鐨勬椂鍊欒繕浠ヤ負鏄?DP , 鐪嬫噦棰樼洰鍚庣煡閬撹繖鍙槸涓涓畝鍗曠殑灝忓鏁板棰?鍛靛懙. 濡傛灉姹傜Щ鍔ㄦ鏁拌繕澶嶆潅鐐? 浣嗛鐩姹傜殑鏄?鏈灝忔惉鍔ㄦ鏁? 閭d箞鍙姹傚嚭騫沖潎鍊? 澶т簬騫沖潎鍊肩殑澧欏氨鏄縐誨姩鐨勫 ,绱姞灝卞彲浠ヤ簡.
浠g爜濡備笅:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int N;
int f = 0;
while ( cin >> N, N )
{
if ( f )
{
cout << endl;
}
f = 1;
int num[N+1];
num[N] = 0;
for ( int i = 0; i != N; ++ i )
{
cin >> num[i];
num[N] += num[i];
}
num[N] /= N;
int nCount = 0;
for ( int i = 0; i != N; ++ i )
{
if ( num[i] > num[N] )
{
nCount += num[i] - num[N];
}
}
cout << nCount << endl;
}
return 0;
}
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=2093
棰樼洰鎻忚堪:
C++緙栫▼鑰冭瘯浣跨敤鐨勫疄鏃舵彁浜ょ郴緇燂紝鍏鋒湁鍗蟲椂鑾峰緱鎴愮嘩鎺掑悕鐨勭壒鐐廣傚畠鐨勫姛鑳芥槸鎬庝箞瀹炵幇鐨勫憿錛?br>鎴戜滑鍋氬ソ浜嗛鐩殑瑙g瓟錛屾彁浜や箣鍚庯紝瑕佷箞“AC”錛岃涔堥敊璇紝涓嶇鎬庢牱閿欐硶錛屾繪槸緇欎綘璁頒笂涓絎旓紝琛ㄦ槑浣犳浘緇忔湁榪囦竴嬈¢敊璇彁浜わ紝鍥犺屽綋浣犱竴鏃︽彁浜よ棰?#8220;AC”鍚庯紝灝辮涓庝綘綆椾竴綆楀笎浜嗭紝鎬誨叡璇ラ閿欒鎻愪氦浜嗗嚑鍥炪傝櫧鐒朵綘鍦ㄩ鏁頒笂錛屽ぇ姝ュ湴璺冧笂浜嗕竴涓彴闃訛紝浣嗘槸鍦ㄨ楁椂涓婅鎽婁笂浣犲叡鑺卞幓鐨勬椂闂淬傜壒鍒槸錛屾浘緇忔湁榪囩殑閿欒鎻愪氦錛屾瘡嬈¢兘瑕佹憡涓婁竴瀹氱殑鍗曚綅鏃墮棿鍒嗐傝繖鏍蜂竴鏉ワ紝浣犲湪鍋氬嚭鐨勯鏁頒笂錛屽彲鑳介鍏堝埆浜哄緢澶氾紝浣嗘槸錛屽湪鍋氬嚭鍚屾牱棰樻暟鐨勪漢緹や腑錛屼綘鍙兘浼氬湪鑰楁椂涓婂浜庢帓鍚嶇殑鍔e娍銆?br>渚嬪錛氭煇嬈¤冭瘯涓鍏?棰橈紙A錛孊錛孋錛孌錛孍錛孎錛孏錛孒錛夛紝姣忎釜浜哄仛鐨勯閮藉湪瀵瑰簲鐨勯鍙蜂笅鏈変釜鏁伴噺鏍囪錛岃礋鏁拌〃紺鴻瀛︾敓鍦ㄨ棰樹笂鏈夎繃鐨勯敊璇彁浜ゆ鏁幫紝浣嗗埌鐜板湪榪樻病鏈堿C錛屾鏁拌〃紺篈C鎵鑰楃殑鏃墮棿錛屽鏋滄鏁癮璺熶笂涓瀵規嫭鍙鳳紝閲岄潰鏈変釜鏁存暟b錛岄偅灝辮〃紺鴻瀛︾敓鎻愪氦璇ラAC浜嗭紝鑰楀幓浜嗘椂闂碼錛屽悓鏃訛紝鏇劇粡閿欒鎻愪氦浜哹嬈★紝鍥犳瀵逛簬涓嬭堪杈撳叆鏁版嵁錛?br>
鑻ユ瘡嬈¢敊璇彁浜ょ殑緗氬垎涓?0鍒嗭紝鍒欏叾鎺掑悕浠庨珮鍒頒綆搴旇鏄繖鏍風殑錛?br>Josephus 5 376
John 4 284
Alice 4 352
Smith 3 167
Bob 2 325
Bush 0 0
Input
杈撳叆鏁版嵁鐨勭涓琛屾槸鑰冭瘯棰樻暟n錛?/span>1≤n≤12錛変互鍙婂崟浣嶇綒鍒嗘暟m錛?/span>10≤m≤20錛夛紝姣忚鏁版嵁鎻忚堪涓涓鐢熺殑鐢ㄦ埛鍚嶏紙涓嶅浜?0涓瓧絎︾殑瀛椾覆錛変互鍙婂鎵鏈塶閬撻鐨勭瓟棰樼幇鐘訛紝鍏舵弿榪伴噰鐢ㄩ棶棰樻弿榪頒腑鐨勬暟閲忔爣璁扮殑鏍煎紡錛岃涓婇潰鐨勮〃鏍鹼紝鎻愪氦嬈℃暟鎬繪槸灝忎簬100錛孉C鎵鑰楁椂闂存繪槸灝忎簬1000銆?br>
Output
灝嗚繖浜涘鐢熺殑鑰冭瘯鐜扮姸錛岃緭鍑轟竴涓疄鏃舵帓鍚嶃傚疄鏃舵帓鍚嶆樉鐒跺厛鎸堿C棰樻暟鐨勫灝戞帓錛屽鐨勫湪鍓嶏紝鍐嶆寜鏃墮棿鍒嗙殑澶氬皯鎺掞紝灝戠殑鍦ㄥ墠錛屽鏋滃噾宸у墠涓よ呴兘鐩哥瓑錛屽垯鎸夊悕瀛楃殑瀛楀吀搴忔帓錛屽皬鐨勫湪鍓嶃傛瘡涓鐢熷崰涓琛岋紝杈撳嚭鍚嶅瓧錛?0涓瓧絎﹀錛夛紝鍋氬嚭鐨勯鏁幫紙2涓瓧絎﹀錛屽彸瀵歸綈錛夊拰鏃墮棿鍒嗭紙4涓瓧絎﹀錛屽彸瀵歸綈錛夈傚悕瀛椼侀鏁板拰鏃墮棿鍒嗙浉浜掍箣闂存湁涓涓┖鏍箋?br>
Sample Input
8 20
Smith -1 -16 8 0 0 120 39 0
John 116 -2 11 0 0 82 55(1) 0
Josephus 72(3) 126 10 -3 0 47 21(2) -2
Bush 0 -1 -8 0 0 0 0 0
Alice -2 67(2) 13 -1 0 133 79(1) -1
Bob 0 0 57(5) 0 0 168 -7 0
Sample Output
Josephus 5 376
John 4 284
Alice 4 352
Smith 3 167
Bob 2 325
Bush 0 0
棰樼洰鍒嗘瀽 :
綰補鑰冮獙緙栫▼鑳藉姏鐨勯, 灝變氦緇欒嚜宸遍槦閲岀殑浠g爜鐗涗漢瑙e喅鍚?, 涓昏鏄嬌鐢?sscanf () 鐢ㄤ簬鍒ゆ柇 鏈夋病鏈夋嫭鍙?
浠g爜濡備笅:
#include <cstdlib>
#include <cstring>
#define MAX 1000
typedef struct
{
char name[11];
int sum;
int total;
}credit;
int cmp(const void *a, const void *b)
{
if ((*(credit *)a).total != (*(credit *)b).total)
return (*(credit *)a).total - (*(credit *)b).total;
else if ((*(credit *)b).sum != (*(credit *)a).sum)
return (*(credit *)b).sum - (*(credit *)a).sum;
else
return strcmp((*(credit *)b).name, (*(credit *)a).name);
}
int main()
{
int res, t, f;
int i, n, m, j;
char style[10];
credit c[MAX] = {0};
scanf ( "%d%d", &n, &m );
for ( i = 0; scanf("%s", c[i].name) != EOF; i++ )
{
for ( j = 0; j < n; j++ )
{
scanf ( "%s", style );
res = sscanf(style, "%d(%d)", &t, &f );
if ( res == 2 )
{
c[i].total++;
c[i].sum += t + f * m;
}
else if (res == 1 && t > 0)
{
c[i].total++;
c[i].sum += t;
}
}
}
qsort(c, i, sizeof(credit), cmp);
for ( i--; i >= 0; i-- )
{
printf("%-10s %2d %4d\n", c[i].name, c[i].total, c[i].sum);
}
return 0;
}
]]>
棰樼洰鍦板潃:
http://acm.hdu.edu.cn/showproblem.php?pid=2086
棰樼洰鎻忚堪:
鏈夊涓嬫柟紼嬶細Ai = (Ai-1 + Ai+1)/2 - Ci (i = 1, 2, 3,
. n).
鑻ョ粰鍑篈0, An+1, 鍜?nbsp;C1, C2,
..Cn.
璇風紪紼嬭綆桝1 = ?
Input
杈撳叆鍖呮嫭澶氫釜嫻嬭瘯瀹炰緥銆?br>瀵逛簬姣忎釜瀹炰緥錛岄鍏堟槸涓涓鏁存暟n,(n <= 3000); 鐒跺悗鏄?涓暟a0, an+1.鎺ヤ笅鏉ョ殑n琛屾瘡琛屾湁涓涓暟ci(i = 1,
.n);杈撳叆浠ユ枃浠剁粨鏉熺緇撴潫銆?br>
Output
瀵逛簬姣忎釜嫻嬭瘯瀹炰緥錛岀敤涓琛岃緭鍑烘墍姹傚緱鐨刟1(淇濈暀2浣嶅皬鏁?.
Sample Input
1
50.00
25.00
10.00
2
50.00
25.00
10.00
20.00
Sample Output
27.50
15.00
榪欓亾棰樼殑鍏抽敭鍦ㄤ簬鍏紡鐨勬帹瀵? 鍏紡鎺ㄥ嚭鏉ラ棶棰樺氨瑙e喅浜?
. n). 鐢ˋ5鍋氱ず鑼冿紝灝辮兘鐚滄祴鍑哄叕寮忔潵銆傝瘉鏄庢柟娉曞彲浠ラ噰鐢ㄦ暟瀛﹀綊綰蟲硶銆傝繖閲岃瘉鏄庝粠鐣ャ?br>A5 = (A4 + A6) / 2 - C5
A4 = (A3 + A5) / 2 - C4 = A3 / 2 + A4 / 4 + A6 / 4 - C5 / 2 - C4
=>A4 = 2A3/3 + A6/3 - 2C5/3 - 4C4/3
A3 = (A2 + A4) / 2 - C3 = A2 / 2 + A3 / 3 + A6 / 6 - C5 / 3 - 2C4 / 3 - C3
=>A3 = 3A2/4 + A6/4 - C5/2 - C4 - 3C3/2
A2 = (A1 + A3) / 2 - C2 = A1 / 2 + 3A2 / 8 + A6 / 8 - C5 / 4 - C4 / 2 - 3C3 / 4 - C2
=>A2 = 4A1/5 + A6/5 - 2C5/5 - 4C4/5 - 6C3/5 - 8C2/5
A1 = (A0 + A2) / 2 - C1 = A0 / 2 + 2A1 / 5 + A6 / 10 - C5 / 5 - 2C4 / 5 - 3C3 / 5 - 4C2 / 5 - C1
=>A1 = 5A0/6 + A6/6 - C5/3 - 2C4/3 - C3 - 4C2/3 - 5C1/3
綆楀埌榪欓噷錛屾垜鎯充綘宸茬粡鎬葷粨鍑哄叕寮忎簡:
A1 = (n * A0 + An+1 - 2 * Cn - 4 * Cn-1 -
- 2 * i * Cn-i+1 - 2 * n * C1) / (n + 1)
浠g爜濡備笅 :
#include <stdio.h>
int main ()
{
int n, i;
double a0, an1, a1;
double c[3000];
while ( scanf ( "%d", &n) != EOF )
{
scanf ( "%lf%lf", &a0, &an1 );
for ( i = 0; i < n; i++ )
{
scanf("%lf", c + i);
}
a1 = n * a0 + an1;
for ( i = 1; i <= n; i++ )
{
a1 -= 2 * i * c[n - i];
}
printf ( "%.2f\n", a1 / ( n + 1 ) );
}
return 0;
}
]]>