Search
 
SCRIPT & CODE EXAMPLE
 

CPP

round c++

#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 
Comment

round c++

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
Comment

PREVIOUS NEXT
Code Example
Cpp :: C++, binary search recursive 
Cpp :: right shift in c++ 
Cpp :: c++ pointers and arrays 
Cpp :: custom slider cpt wordpress theme 
Cpp :: operator overloading in c++ 
Cpp :: cin c++ 
Cpp :: cpp custom exception 
Cpp :: valid parentheses in cpp 
Cpp :: c++ check first character of string 
Cpp :: c++ power of two 
Cpp :: c++ main function parameters 
Cpp :: cpp foreach 
Cpp :: remove elements from vector 
Cpp :: sstream c++ 
Cpp :: print all number between a and b in c++ 
Cpp :: rc.local not running centos 6 
Cpp :: pointer to value of others file cpp 
Cpp :: the amount of input is unknown 
Cpp :: parking charge system project c++ 
Cpp :: how to type a vertical stack program c++ 
Cpp :: c++ vector move element 
Cpp :: practice problems for nested loops in c++ 
Cpp :: string in int in cpp 
Cpp :: CodeChef Starters 30 Division 4 (Rated) Swapping Chefs Way 
Cpp :: multi variable assignment cpp 
Cpp :: how to draw a rectangle with diagonals and axes of symmetry in c ++ in the console? 
Cpp :: a suprise... c++ 
Cpp :: dfs in tree using adjacency list 
Cpp :: segment tree lazy propogation 
Cpp :: SDL_BlitSurface 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =