cout << "Nearest value of x :" << round(x) << "
";
#include<bits/stdc++.h>
int main() {
using namespace std;
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int T; cin >> T;
for (int case_num = 1; case_num <= T; case_num ++) {
int64_t L, R; cin >> L >> R; R++;
bool parity = 0;
int64_t coeff = 1;
int64_t ans = 0;
while (L < R) {
assert(1 <= L && L < R);
auto is_good = [&](int64_t v) {
assert(v > 0);
bool d = v % 2;
while (v > 0) {
if (v % 2 != d) return false;
d = !d;
v /= 10;
}
return d == 0;
};
while (L < R && L % 10 != 0) {
if (is_good(L)) {
ans += coeff;
}
L++;
}
while (L < R && R % 10 != 0) {
--R;
if (is_good(R)) {
ans += coeff;
}
}
if (L == R) break;
assert(L % 10 == 0 && R % 10 == 0);
assert(L >= 10);
L /= 10;
sorry for the error
value round floor ceil trunc
----- ----- ----- ---- -----
2.3 2.0 2.0 3.0 2.0
3.8 4.0 3.0 4.0 3.0
5.5 6.0 5.0 6.0 5.0
-2.3 -2.0 -3.0 -2.0 -2.0
-3.8 -4.0 -4.0 -3.0 -3.0
-5.5 -6.0 -6.0 -5.0 -5.0
Code Example |
---|
Cpp :: c++ suare |
Cpp :: template in cpp |
Cpp :: c++ struktura kolejki |
Cpp :: cuda atomic swap |
Cpp :: c++ max |
Cpp :: how to implement stack |
Cpp :: c++ find string in string |
Cpp :: c++ multi-dimensional arrays |
Cpp :: cin in c++ |
Cpp :: default access specifier in c++ |
Cpp :: iteration in c++ |
Cpp :: split string by delimiter cpp |
Cpp :: c vs c++ vs c# |
Cpp :: run with cpp version |
Cpp :: c++ pwstr to char* |
Cpp :: tan ^-1 ti 83 |
C :: sleep in c programming |
C :: .gitkeep file |
C :: c program hide console window |
C :: same project on different monitor in intellij mac |
C :: bootstrap 5 modal not working vue js 3 |
C :: C program to display fibonacci serice |
C :: write a program in c to check whether the number is armstrong or not |
C :: c programming itoa() example |
C :: how to create calculator with switch in c |
C :: c program to find minimum of 4 numbers using conditional operator in c |
C :: c if else |
C :: c to llvm |
C :: prime number c program |
C :: equal string c |