http://acm.hdu.edu.cn/showproblem.php?pid=5920
http://www.cnblogs.com/xudong-bupt/p/4015226.html
把前半部分复制过去,如果太大,那么早到第一个会使得其太大的点,减1,然后对应的中间的变成9
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <string> #include <stack> #include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime> #define X first #define Y second #define clr(u,v); memset(u,v,sizeof(u)); #define in() freopen("3.h","r",stdin); #define out() freopen("ans","w",stdout); #define Clear(Q); while (!Q.empty()) Q.pop(); #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; const ll INF = 1e17; const int inf = 0x3f3f3f3f; const int maxn = 1e3 + 20; char nxt[maxn], str[maxn]; bool is(char str[], int lenstr) { int i = 1, j = lenstr; while (i < j) { if (str[i] != str[j]) return false; ++i; --j; } return true; } void bigCut(char str[], char sub[], char str3[]) { int lenstr = strlen(str + 1), lensub = strlen(sub + 1); // printf("%d ", lenstr); for (int i = 1; i <= lenstr; ++i) str[i] -= '0'; for (int i = 1; i <= lensub; ++i) sub[i] -= '0'; int use = lenstr; for (int i = lensub; i >= 1; --i, --use) { if (str[use] < sub[i]) { str[use] = 10 + str[use] - sub[i]; int p = use - 1; while (p >= 1 && !str[p]) { str[p] = 9; p--; } str[p]--; } else str[use] -= sub[i]; } for (int i = 1; i <= lenstr; ++i) str[i] += '0'; int to = 0; int p = 1; while (p < lenstr && str[p] == '0') p++; while (p <= lenstr) { str3[++to] = str[p++]; } str3[++to] = '