【再水一天,明天開始計算幾何&母函數】補遺PJ 2370及其他兩水題

來源:互聯網
上載者:User

    既然回到原點,那就從原點開始吧……

    第一道題: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))……恭喜你,上當了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.