wojiaocbj

Untitled

May 18th, 2022
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #pragma warning(disable:4996)
  7. typedef long long s64, LL;
  8. typedef unsigned long long u64, ULL;
  9. int ans[16] = { 0 };
  10. char check(LL k){
  11.     int cur;
  12.     while(k){
  13.         cur = k % 10;
  14.         if(!ans[cur]){
  15.             return 1;
  16.         }
  17.         ans[cur]--;
  18.         k /= 10;
  19.     }
  20.     return 0;
  21. }
  22. int main(){
  23. #ifdef _DEBUG
  24.     FILE *fp = freopen("../../../input.txt", "r", stdin);
  25.     //FILE *fp2 = freopen("../../../output.txt", "w", stdout);
  26. #endif // _DEBUG
  27.     int i;
  28.     LL x;
  29.     for(i = 0; i < 10; i++){
  30.         scanf("%d", ans + i);
  31.     }
  32.     scanf("%lld", &x);
  33.     for(;;){
  34.         if(check(x)){
  35.             printf("%lld\n", x - 1);
  36.             break;
  37.         }
  38.         x++;
  39.     }
  40. #ifdef _DEBUG
  41.     fp = freopen("CON", "r", stdin);
  42.     //fp2 = freopen("CON", "w", stdout);
  43.     system("pause");
  44. #endif // _DEBUG
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment