漏写的数字

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;



int cmp(const void * x, const void * y) {
#define datatype int
    datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
    //x < y
    return dx > dy ? 1 : -1;
#undef datatype
}

char str[500];
int s[500];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    std::ios::sync_with_stdio(0), cin.tie(0);
    cin >> str;
    bool f, f1;
    int n = strlen(str);
    for (int i = 0; i < n; i++) s[i] = str[i] - '0';
    int ans;
    f = true, f1 = false;
    int b = s[0];
    int ptr = 1;
    while (ptr < n) {
        b++;
        if (b < 10) {
            if (s[ptr] == b) {
                ptr++;
                continue;
            } else {
                if (f1) {
                    f = false;
                    break;
                } else {
                    f1 = true;
                    ans = b;
                }
            }
        } else {
            if (s[ptr] == b / 10 && s[ptr + 1] == b % 10) {
                ptr += 2;
                continue;
            } else {
                if (f1) {
                    f = false;
                    break;
                } else {
                    f1 = true;
                    ans = b;
                }
            }
        }
    }
    if (f && f1) {
        cout << ans << endl;
        return 0;
    }
    f = true, f1 = false;
    b = s[0] * 10 + s[1];
    ptr = 2;
    while (ptr < n) {
        b++;
        if (b < 10) {
            if (s[ptr] == b) {
                ptr++;
                continue;
            } else {
                if (f1) {
                    f = false;
                    break;
                } else {
                    f1 = true;
                    ans = b;
                    ptr++;
                }
            }
        } else {
            if (s[ptr] == b / 10 && s[ptr + 1] == b % 10) {
                ptr += 2;
                continue;
            } else {
                if (f1) {
                    f = false;
                    break;
                } else {
                    f1 = true;
                    ans = b;
                }
            }
        }
    }
    if (f && f1) {
        cout << ans << endl;
        return 0;
    }
    return 0;
}
View Code

相关文章: