fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve() {
  5. string x, y;
  6. cin >> x >> y;
  7. int a = stoi(x);
  8. int b = stoi(y);
  9. if (a == b) {
  10. cout << "NO" << endl;
  11. return;
  12. }
  13. if (a + 1 == b) {
  14. cout << "YES" << endl;
  15. return;
  16. }
  17. if (b == 1) {
  18. if (a % 9 == 0) {
  19. cout << "YES" << endl;
  20. } else {
  21. cout << "NO" << endl;
  22. }
  23. } else {
  24. if (b > a) {
  25. cout << "NO" << endl;
  26. return;
  27. }
  28. if ((a - b - 1) % 9 == 0) cout << "YES" << endl;
  29. else cout << "NO" << endl;
  30. }
  31. }
  32.  
  33. int main() {
  34. int t;
  35. cin >> t;
  36. while (t--) solve();
  37. }
Success #stdin #stdout 0.01s 5284KB
stdin
7
1 2
77 77
997 999
999 1
1000 1
1 11
18 1
stdout
YES
NO
NO
YES
NO
NO
YES