Codeforces beta round #96 (Div. 2)

Source: Internet
Author: User
C. Turing tapetime limit per test

2 seconds

Memory limit per test

256 megabytes

Input

Standard Input

Output

Standard output

Intercal is the oldest of esoteric programming ages. one of its unique weird features is the method of character-based output, known as Turing tape method. it converts an array of unsigned 8-bit integers into a sequence of characters to print, using
Following method.

The Integers of the array are processed one by one, starting from the first. ProcessingI-Th element of the array is done in three steps:

1. the 8-bit binary notation of the ascii-code of the previous printed character is reversed. when the first element of the array is processed, the result of this step is considered to be 0.

2.I-Th element of the array is subtracted from the result of the previous step modulo 256.

3. the binary notation of the result of the previous step is reversed again to produce ascii-code ofI-Th character to be printed.

You are given the text printed using this method. Restore the array used to produce this text.

<P = "" style = "font-family: verdana, Arial, sans-serif; font-size: 14px; line-Height: 21px; "> <p =" ">

Input

<P = "">

The input will consist of a single lineTextWhich contains the message printed using the described method. StringTextWill
Contain Between 1 and 100 characters, intrusive. ascii-code of each characterTextWill be between 32 (Space) and 126 (Tilde), inclusive.

<P = ""> <p = "">

Output

<P = "">

Output the initial array, which was used to produceText, One integer per line.

<P = ""> <p = "">

Sample test (s)

<P = ""> <p = "">

Input
Hello, World!
Output
23810811206419448262441682416162

<P = ""> <p = "">

Note

<P = "">

Let's have a closer look at the beginning of the example. The first character is "H" with ASCII-code 72 character = Limit 010010002.
Its reverse is 000100102 rows = Limit 18, and this number shocould become the result of the second step of processing. The result of the first
Step is considered to be 0, so the first element of the array has to be (0 Lower-limit 18) mod 256 lower = Lower 238,
WhereAMoDBIs the remainder of divisionAByB.

  1. #include<iostream>using namespace std;int main(){    char str[200];    int num, i, j, k;    int pre = 0;    char temp[10];    cin.getline(str,200,'\n');    for ( i = 0; str[i] != 0; i++ )    {        num = str[i]; j = 0;        while ( num != 0  )        {            k = num % 2;            temp[j++] = k + '0';            num = ( num - k ) / 2;        }        while ( j < 8 ) temp[j++] = '0';        temp[j] = '\0';        for ( j = 0; j < 8; j++ )            num += (temp[j] -'0') << (7-j) ;        //cout << "##" << temp << ' ' << num << endl;        k = (pre - num ) % 256;        if ( k < 0 ) k += 256;        cout << k << endl;        pre = num;    }    return 0;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.