构造+暴力 Codeforces Round #283 (Div. 2) B. Secret Combination

时间:2021-09-16 02:03:19

题目传送门

 /*
构造+暴力:按照题目意思,只要10次加1就变回原来的数字,暴力枚举所有数字,string大法好!
*/
/************************************************
Author :Running_Time
Created Time :2015-8-3 8:43:02
File Name :A.cpp
*************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ;
string mn, now, str;
int n; int main(void) { //Codeforces Round #283 (Div. 2) B. Secret Combination
while (cin >> n) {
cin >> str; mn = str; now = str;
for (int i=; i<=; ++i) {
for (int j=; j<n; ++j) {
if (now[j] == '') now[j] = '';
else now[j]++;
}
cout << now << endl;
for (int j=; j<n; ++j) {
string tmp = "";
for (int k=j; k<n; ++k) tmp += now[k];
for (int k=; k<j; ++k) tmp += now[k];
if (tmp < mn) mn = tmp;
}
}
cout << mn << endl;
} return ;
}