d490. 我也愛偶數

解法一

✅ 完整代碼

評分結果(參考) : AC (2ms, 348KB)

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b;
    cin >> a >> b;
    
    if(a & 1) a++;
    if(b & 1) b--;
    
    if(b >= a) cout << (a+b)*((b-a)/2+1)/2;
    else cout << 0;
    
    return 0;
}