#45405: cpp 超級簡單解


1121232@stu.wghs.tp.edu.tw (Ian911436)

學校 : 臺北市私立薇閣高級中學
編號 : 258883
來源 : [60.248.154.143]
最後登入時間 :
2025-05-14 15:36:23
c022. 10783 - Odd Sum -- UVa10783 | From: [60.248.154.143] | 發表日期 : 2025-02-26 15:52

#include <bits/stdc++.h>
using namespace std;

int main() {
    int a, b, n, e, f = 0;
    cin >> n;  // 讀取測試案例數量
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        e = 0;

        while (a <= b) {  // 當 a 還沒有超過 b 時繼續執行
            if (a % 2 == 1) {
                e = e + a;
            }
            a = a + 1;
        }

        f = f + 1;
        cout << "Case " << f << ": " << e << endl;
    }
    return 0;
}

 
ZeroJudge Forum