//這題只是讓你求給出的數的平均數即可!再通過續一比較,不夠平均數的就從多於平均數中補上! #include <iostream>using namespace std;int num[55];int main(){ int n, i, tc = 0, sum, avg, ans; while (cin >> n) { if (n == 0) break; tc++; sum = ans = 0;
//這題貢獻了兩次RE,因為我開始是這樣想的:只要在輸入的過程中,有fuse大於其c值的,就中斷輸入,直接輸出結果就結束,誰知道RE了! #include <iostream>using namespace std;struct Info{ int fuse; bool state;}devices[30];int main(){ int n, m, c, i, j, op, ans, sum, tc = 0; bool flag; while
//判斷共線的最大點數有多少個?!根據斜率判斷,為避免斜率不存在的情況,改為乘法比較簡單一點! #include <iostream>#include <climits>using namespace std;struct Info{ int x; int y;}cor[705];int main(){ int n, i, j, k, ans, max; double k1, k2; while (cin >> n) {
//同題目1118的原理是一樣的!只是改一改輸入就可以了! #include <iostream>#include <climits>using namespace std;struct Info{ int x; int y;}cor[205];int main(){ int n, i, j, k, ans, max; cin >> n; ans = 0; max = 0; for (i = 1;
//給出總的路程,然後再選擇訓練的地圖,記得去的時候,如果是上坡的,返回的時候就變成了下坡,如果是下坡的,返回的時候就變成了上坡!//總之路程就是雙程!問最多可以有幾個地圖可以選擇的! #include <iostream>#include <string>using namespace std;char unit[100005];int main(){ int m, t, u, f, d, i, ans = 0, sum = 0; cin >>
//通過讀鐘錶上面的點數,計算出需要strike的次數,很簡單,將字串轉換為數字就OK! #include <iostream>#include <string>using namespace std;int main(){ int tc, len, i, j, h, m; string time; cin >> tc; while (tc--){ cin >> time; h = m =
//給出一段距離,即是樹木的總數,然後再給出幾個樹木需要砍伐或者移走的地區,求剩下的樹木數!注意://That's to say that there used to be 301 trees on the road. Now the section from 100m to 200m //is assigned for subway station, so 101 trees need to be moved away and only 200 trees are left.
//這題需要注意邊界的處理!就開始我以為需要用動態規劃做的,誰知道這題只是需要從頭到尾進行//一次掃描即可,找出每一個高峰點就OK!哎,將簡單的問題複雜化了,歸根是沒有真正讀懂題意! #include <iostream>using namespace std;int h[50050];int main(){ int n, i; cin >> n; for (i = 1; i <= n; i++){ cin >> h[i]
#include <iostream>#include <string>using namespace std;int main(){ string str1, str2, str3; int m, ans = 0; while (cin >> str1) { if (str1 == "0") { cout << ans << endl;