Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Task1881 implements Runnable {
  5.  
  6. private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
  7.  
  8. private BufferedReader in;
  9. private PrintWriter out;
  10. private StringTokenizer tok = new StringTokenizer("");
  11.  
  12. private void init() throws FileNotFoundException {
  13. Locale.setDefault(Locale.US);
  14. String fileName = "";
  15. if (ONLINE_JUDGE && fileName.isEmpty()) {
  16. in = new BufferedReader(new InputStreamReader(System.in));
  17. out = new PrintWriter(System.out);
  18. } else {
  19. if (fileName.isEmpty()) {
  20. in = new BufferedReader(new FileReader("input.txt"));
  21. out = new PrintWriter("output.txt");
  22. } else {
  23. in = new BufferedReader(new FileReader(fileName + ".in"));
  24. out = new PrintWriter(fileName + ".out");
  25. }
  26. }
  27. }
  28.  
  29. String readString() {
  30. while (!tok.hasMoreTokens()) {
  31. try {
  32. tok = new StringTokenizer(in.readLine());
  33. } catch (Exception e) {
  34. return null;
  35. }
  36. }
  37. return tok.nextToken();
  38. }
  39.  
  40. int readInt() {
  41. return Integer.parseInt(readString());
  42. }
  43.  
  44. long readLong() {
  45. return Long.parseLong(readString());
  46. }
  47.  
  48. double readDouble() {
  49. return Double.parseDouble(readString());
  50. }
  51.  
  52.  
  53. public static void main(String[] args) {
  54. //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
  55. new Task1881().run();
  56. }
  57.  
  58.  
  59. @Override
  60. public void run() {
  61. try {
  62.  
  63. init();
  64. solve();
  65. out.close();
  66.  
  67. } catch (Exception e) {
  68. e.printStackTrace();
  69. System.exit(-1);
  70. }
  71. }
  72.  
  73.  
  74. private void solve() throws IOException {
  75. char[] c = in.readLine().toCharArray();
  76.  
  77. for(int i = 0; i < c.length; i++){
  78. c[i]-=97;
  79. }
  80.  
  81.  
  82. if (c[0] - 5 < 0) {
  83. c[0] += 26;
  84. }
  85.  
  86. for(int i = 1; i < c.length; i++){
  87. if (c[i] < c[i-1]){
  88. while(c[i] < c[i-1]){
  89. c[i]+=26;
  90. }
  91. }
  92. }
  93. for(int i = c.length - 1; i > 0; i--){
  94. c[i] -= c[i-1];
  95. }
  96. c[0] -= 5;
  97. for(int i = 0; i < c.length; i++){
  98. c[i]+=97;
  99. }
  100.  
  101. for(int i = 0; i < c.length; i++){
  102. out.print(c[i]);
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110. }
  111.  
  112.  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement