Guest User

Untitled

a guest
Mar 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. string decrypt( const string& word )
  7. {
  8. // your code goes here
  9.  
  10. string source(word.length(),' ');
  11. int i = 0;
  12. int prefixSum = 0;
  13.  
  14. for(char c : word){
  15. source[i] = word[i] - 1 - prefixSum;
  16. prefixSum += source[i];
  17.  
  18. while(source[i] <'a' || source[i] > 'z')
  19. source[i] += 26;
  20.  
  21. i++;
  22. }
  23.  
  24. return source;
  25. }
  26.  
  27. int main() {
  28. return 0;
  29. }
  30.  
  31. /*
  32. a b c d e f g h i j k l m n o p q r s t u v w x y z
  33. d n o t q
  34.  
  35. c
  36.  
  37. source[0] = encrypt[0] - 1
  38. source[1] = (encrypt[1] - 1 - source[0]) >=a && <= z
  39. while(source[i] >= a && <=z)
  40. source[i] += 26
  41.  
  42. 114 + 100 -> 214 -> 26 * n -> a - z
  43. step 2 number it is sum of series of original chars:
  44. 99 + 1
  45. 99 + 1 + 114
  46. ...
  47.  
  48. encrypt[i] = 1 + source[0] + source[1] +...+ source[i] - 26 * ni -> a - z
  49.  
  50. algebra equation on line 29 -> source[i] -> right hand size, move other terms to left side
  51. source[i] -> induction
  52. encrypt[i] - 1 - source[0] - ... - source[i - 1] + 26 * ni ->
  53. */
Add Comment
Please, Sign In to add comment