#10878: C++ 只需要算數運算子的解答


gary0609tw (shiz)


#include <iostream>
using namespace std;

int main() {
int a,b;
cin >> a>>b ;
cout <<((b-b%2)-(a+a%2))/2+1;

}

#10879: Re:C++ 只需要算數運算子的解答


gary0609tw (shiz)


#include
using namespace std;

int main() {
int a,b;
cin >> a>>b ;
cout <<((b-b%2)-(a+a%2))/2+1;

}



簡單的幾行就解決囉   想超久的  哈哈

#11341: Re:C++ 只需要算數運算子的解答


gary771016 (MrCat)


#include
using namespace std;

int main() {
int a,b;
cin >> a>>b ;
cout <<((b-b%2)-(a+a%2))/2+1;

}

我的是這樣 0~B的偶數個數 - 0~A的偶數個數 + (因為這樣減會少掉A本身 在判斷A本身是否為偶數)

cout<<(b/2 + 1) - (a/2 + 1) + (a%2 == 0)  <<endl;