Advertisement
rjlth

Untitled

Dec 17th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. //Zhandos Kapezov
  2. #include <iostream>
  3. #include <math.h>
  4. #include <cmath>
  5. #include <vector>
  6. #include <utility>
  7. #include <algorithm>
  8. #include <cstdio>
  9. #include <cstdlib>
  10. #include <fstream>
  11. #include <string>
  12. #include <string.h>
  13. #include <sstream>
  14. #include <map>
  15. #include <set>
  16. #include <stack>
  17. #include <queue>
  18. #include <deque>
  19. #include <limits>
  20. #include <list>
  21. #include <functional>
  22. #include <bitset>
  23. #include <numeric>
  24. #include <iomanip>
  25. #include <ctime>
  26. #include <ctype.h>
  27.  
  28. using namespace std;
  29. typedef long long ll;
  30.  
  31. #define F first
  32. #define S second
  33. #define pb push_back
  34. #define mp make_pair
  35. #define sz size()
  36. #define sqr(x) ((x)*(x))
  37. #define INF numeric_limits<int>::max()
  38.  
  39. void f(string &s) {
  40. for (int i=0; i<s.sz; i++) {
  41. s[i]=s[i]+1;
  42. if (s[i]>'9') s[i]='0';
  43. }
  44. }
  45.  
  46. string g(string s) {
  47. string t;
  48. t.resize(s.sz);
  49. s=s+s[0];
  50. for (int i=1; i<=t.sz; i++) t[i-1]=s[i];
  51. return t;
  52. }
  53.  
  54. int n;
  55. string res, s;
  56.  
  57. int main()
  58. {
  59. #ifndef ONLINE_JUDGE
  60. freopen("input.txt","rt",stdin);
  61. freopen("output.txt","wt",stdout);
  62. #endif
  63. cin>>n>>s;
  64. res=s;
  65. for (int i=0; i<n; i++) {
  66. for (int j=0; j<10; j++) {
  67. f(s);
  68. res=min(res, s);
  69. }
  70. s=g(s);
  71. }
  72. cout<<res;
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement