Advertisement
Joao_Joao

Digitos_Diferentes - C

May 15th, 2022
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. /*
  2.   INPUT:
  3.     87 104
  4.     989 1022
  5.     22 25
  6.     1234 1234
  7.   OUTPUT:
  8.     14
  9.     0
  10.     3
  11.     1
  12. */
  13.  
  14. #include <stdio.h>
  15.  
  16. #define f(i, s, t) for (int i = s; i < t; ++i)
  17.  
  18. int main() {
  19.   int n, m, a, b, c, d, ans;
  20.   while(scanf("%d%d", &n, &m) != EOF) {
  21.     ans = 0;
  22.     f(i,n,m+1) {
  23.       a = i / 1000, b = i % 1000 / 100,
  24.       c = i % 100 / 10, d = i % 10;
  25.       if(!a) a = -1;
  26.       if(!b && a == -1) b = -1;
  27.       if(!c && b == -1) c = -1;
  28.       if((a == -1 || (a != b && a != c && a != d)) && (b == -1 || (b != c && b != d)) && (c == -1 || (c != d))) {
  29.         ++ans;
  30.       }
  31.     }
  32.     printf("%d\n", ans);
  33.   }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement