fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. template<class T, class U> inline T GCD_L(T a, U b){
  5. T r;
  6. while(b){
  7. r=a;
  8. a=b;
  9. b=r%a;
  10. }
  11. return a;
  12. }
  13. template<class S, class T> inline S chmin(S &a, T b){
  14. if(a>b){
  15. a=b;
  16. }
  17. return a;
  18. }
  19. #define main dummy_main
  20. int main(){
  21. return 0;
  22. }
  23. #undef main
  24. class Solution{
  25. public:
  26. string findLexSmallestString(string s, int a, int b){
  27. int KL2GvlyY;
  28. int n = s.size();
  29. string res = s;
  30. string tmp;
  31. string t;
  32. b =GCD_L(b, n);
  33. int Q5VJL1cS = n/b;
  34. for(KL2GvlyY=(0);KL2GvlyY<(Q5VJL1cS);KL2GvlyY++){
  35. int RZTsC2BF;
  36. tmp = t = s;
  37. for(RZTsC2BF=(0);RZTsC2BF<(10);RZTsC2BF++){
  38. int i;
  39. for(i=(1);i<(n);i+=(2)){
  40. t[i] = (t[i]-'0'+a) % 10 + '0';
  41. }
  42. chmin(tmp, t);
  43. }
  44. if(b%2){
  45. int KrdatlYV;
  46. t = tmp;
  47. for(KrdatlYV=(0);KrdatlYV<(10);KrdatlYV++){
  48. int i;
  49. for(i=(0);i<(n);i+=(2)){
  50. t[i] = (t[i]-'0'+a) % 10 + '0';
  51. }
  52. chmin(tmp, t);
  53. }
  54. }
  55. chmin(res, tmp);
  56. s = s.substr(b) + s.substr(0,b);
  57. }
  58. return res;
  59. }
  60. }
  61. ;
  62. // cLay varsion 20201018-2
  63.  
  64. // --- original code ---
  65. // #define main dummy_main
  66. // {}
  67. // #undef main
  68. //
  69. // class Solution {
  70. // public:
  71. // string findLexSmallestString(string s, int a, int b) {
  72. // int n = s.size();
  73. // string res = s, tmp, t;
  74. //
  75. // b = gcd(b, n);
  76. // REP(n/b){
  77. // tmp = t = s;
  78. // rep(10){
  79. // rep(i,1,n,2) t[i] = (t[i]-'0'+a) % 10 + '0';
  80. // tmp <?= t;
  81. // }
  82. // if(b%2){
  83. // t = tmp;
  84. // rep(10){
  85. // rep(i,0,n,2) t[i] = (t[i]-'0'+a) % 10 + '0';
  86. // tmp <?= t;
  87. // }
  88. // }
  89. // res <?= tmp;
  90. // s = s.substr(b) + s.substr(0,b);
  91. // }
  92. //
  93. // return res;
  94. // }
  95. // };
  96.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty