Promi_38

cf 1462C

Jan 17th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.     int t;
  7.     scanf("%d", &t);
  8.    
  9.     while(t--)
  10.     {
  11.         int x;
  12.         scanf("%d", &x);
  13.         if(x <= 9) printf("%d\n", x);
  14.         else if(x >= 10 && x <= 17) printf("%d9\n", (x % 10) + 1);
  15.         else if(x >= 18 && x <= 24) printf("%d89\n", x - 17);
  16.         else if(x >= 25 && x <= 30) printf("%d789\n", x - 24);
  17.         else if(x >= 31 && x <= 35) printf("%d6789\n", x - 30);
  18.         else if(x >= 36 && x <= 39) printf("%d56789\n", x - 35);
  19.         else if(x >= 40 && x <= 42) printf("%d456789\n", x - 39);
  20.         else if(x >= 43 && x <= 44) printf("%d3456789\n", x - 42);
  21.         else if(x == 45) printf("123456789\n");
  22.         else printf("-1\n");
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment