Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <ctype.h>
- #pragma warning(disable:4996)
- typedef long long s64, LL;
- typedef unsigned long long u64, ULL;
- int ans[16] = { 0 };
- char check(LL k){
- int cur;
- while(k){
- cur = k % 10;
- if(!ans[cur]){
- return 1;
- }
- ans[cur]--;
- k /= 10;
- }
- return 0;
- }
- int main(){
- #ifdef _DEBUG
- FILE *fp = freopen("../../../input.txt", "r", stdin);
- //FILE *fp2 = freopen("../../../output.txt", "w", stdout);
- #endif // _DEBUG
- int i;
- LL x;
- for(i = 0; i < 10; i++){
- scanf("%d", ans + i);
- }
- scanf("%lld", &x);
- for(;;){
- if(check(x)){
- printf("%lld\n", x - 1);
- break;
- }
- x++;
- }
- #ifdef _DEBUG
- fp = freopen("CON", "r", stdin);
- //fp2 = freopen("CON", "w", stdout);
- system("pause");
- #endif // _DEBUG
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment