SHARE
TWEET

Untitled

nikolayneykov May 28th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function mod (number, divisor) {
  2.   let result = 0
  3.  
  4.   for (let i = 0; i < number.length; i++) {
  5.     result = (result * 10 + +number[i] - '0') % divisor
  6.   }
  7.  
  8.   return result
  9. }
  10.  
  11. function divide (number, divisor) {
  12.   let ans = ''
  13.   let index = 0
  14.   let temp = +number[index]
  15.  
  16.   while (temp < divisor) {
  17.     temp = temp * 10 + +number[++index]
  18.   }
  19.  
  20.   index++
  21.   while (number.length >= index) {
  22.     ans += ~~(temp / divisor)
  23.     temp = (temp % divisor) * 10 + +number[index++]
  24.   }
  25.  
  26.   return ans || '0'
  27. }
  28.  
  29. let digits = []
  30.  
  31. for (let i = 65; i <= 90; i++) {
  32.   digits.push(String.fromCharCode(i))
  33. }
  34.  
  35. for (let i = 97; i <= 122; i++) {
  36.   for (let j = 65; j <= 90; j++) {
  37.     digits.push(String.fromCharCode(i) + String.fromCharCode(j))
  38.   }
  39. }
  40.  
  41. let n = gets()
  42. let result = []
  43.  
  44. do {
  45.   result.unshift(digits[mod(n, 256)])
  46.   n = divide(n, 256)
  47. } while (n !== '0')
  48.  
  49. print(result.join(''))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top