既然回到原點,那就從原點開始吧……
第一道題:POJ 2370 題目考英文閱讀,大意就是求最少的支援人數,組數折半+1,每組的人折半+1 ,7.16 PROBLEM A...
這個重寫,一次過了……
#include <iostream>#include <algorithm>using namespace std;bool cmp(int a,int b){return a<b;}int people[101];int main(){int testcase,result=0;cin>>testcase;for(int i=0;i<testcase;i++){cin>>people[i];}int temp=(testcase/2)+1;sort(people,people+testcase,cmp);for(int j=0;j<temp;j++){result+=((people[j]/2)+1);}cout<<result<<endl;return 0;}
當時可能想複雜了…………好吧……水題只要能難住人,也不算水題吧。
明天搞母函數&樹狀數組。。話說母函數從來沒聽說過……看HDU的課件,感覺很好玩的樣子……
這個是求A^B的後三位,HDU 2035,和rightmost digit一樣,會取餘就行。。這也是個常見的思想。
#include <iostream>using namespace std;int misimple(int a,int b){int temp=a%1000;if(temp==0){return 0;}for(int i=1;i<b;i++){temp*=a;temp%=1000;}return temp;}int main(){int a,b;while(cin>>a>>b && (a!=0 && b!=0)){cout<<misimple(a,b)<<endl;}return 0;}
還有 有一種很坑爹的描述,自我提醒:
輸入以負數結尾,範例給的-1 -1 結束。然後你就習慣性的寫了while(cin>>a>>b && (a!=-1 &&b!=-1))……恭喜你,上當了。