Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Zhandos Kapezov
- #include <iostream>
- #include <math.h>
- #include <cmath>
- #include <vector>
- #include <utility>
- #include <algorithm>
- #include <cstdio>
- #include <cstdlib>
- #include <fstream>
- #include <string>
- #include <string.h>
- #include <sstream>
- #include <map>
- #include <set>
- #include <stack>
- #include <queue>
- #include <deque>
- #include <limits>
- #include <list>
- #include <functional>
- #include <bitset>
- #include <numeric>
- #include <iomanip>
- #include <ctime>
- #include <ctype.h>
- using namespace std;
- typedef long long ll;
- #define F first
- #define S second
- #define pb push_back
- #define mp make_pair
- #define sz size()
- #define sqr(x) ((x)*(x))
- #define INF numeric_limits<int>::max()
- void f(string &s) {
- for (int i=0; i<s.sz; i++) {
- s[i]=s[i]+1;
- if (s[i]>'9') s[i]='0';
- }
- }
- string g(string s) {
- string t;
- t.resize(s.sz);
- s=s+s[0];
- for (int i=1; i<=t.sz; i++) t[i-1]=s[i];
- return t;
- }
- int n;
- string res, s;
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt","rt",stdin);
- freopen("output.txt","wt",stdout);
- #endif
- cin>>n>>s;
- res=s;
- for (int i=0; i<n; i++) {
- for (int j=0; j<10; j++) {
- f(s);
- res=min(res, s);
- }
- s=g(s);
- }
- cout<<res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement