A Method for directly solving brute force attacks and a method for directly determining X % 11.
By creating a table, we can find that the two solutions are different in a very small range,
Therefore, start the brute-force enumeration from L and find the output value of the first error. If the value exceeds R, find-1.
# Include <iostream> # include <cstdlib> # include <cstring> # include <string> # include <cstdio> # include <cmath> # include <algorithm> # include <vector> # include <queue> # include <map> # define INF 0x3f3f3f3f # pragma comment (linker, "/Stack: 16777216") # define EPS 1e-6 # define ll long longusing namespace STD; bool judge (ll x) {ll odd = 0, even = 0, flag = 0; while (x> 0) {If (FLAG) {odd + = x % 10; flag = 0;} else {even + = x % 10; flag = 1 ;} x/= 10;} return (even-odd = 3);} int main () {ll l, R; int t; scanf ("% d ", & T); While (t --) {CIN> L> r; while (L <= r) {If (L % 11 = 3) ^ judge (L) break; l ++;} If (L> r) printf ("-1 \ n"); else cout <L <Endl ;} return 0 ;}