Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- int t;
- scanf("%d", &t);
- while(t--)
- {
- int x;
- scanf("%d", &x);
- if(x <= 9) printf("%d\n", x);
- else if(x >= 10 && x <= 17) printf("%d9\n", (x % 10) + 1);
- else if(x >= 18 && x <= 24) printf("%d89\n", x - 17);
- else if(x >= 25 && x <= 30) printf("%d789\n", x - 24);
- else if(x >= 31 && x <= 35) printf("%d6789\n", x - 30);
- else if(x >= 36 && x <= 39) printf("%d56789\n", x - 35);
- else if(x >= 40 && x <= 42) printf("%d456789\n", x - 39);
- else if(x >= 43 && x <= 44) printf("%d3456789\n", x - 42);
- else if(x == 45) printf("123456789\n");
- else printf("-1\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment