CF132A题解
bj12z_donglinxi · · 题解
分析
本题的难点就在于理解题,其实这就是一道模拟,码中没有任何难点,至于二进制反转……
二进制转换其实就是将一个数
x += first % 2 * temp;
temp /= 2;
first /= 2;
另外,题目中给出的 ASCII 码值只到
代码
#include <iostream>
#include <cstring>
#include <cstdio>
//誓死不用万能头
using namespace std;
int last = 0, x = 0;
int first, temp;//first用来存储初始值
string s;
int main() {
getline(cin, s);//避免空格问题,整行读入
for (int i = 0 ; i < s.size() ; i++) {
x = 0;//记得再归零一次(我被卡了几次(可以看我提交记录))
first = s[i];
temp = 128;
for (int j = 1 ; j <= 8 ; j++) {
x += first % 2 * temp;
temp /= 2;
first /= 2;
}
printf("%d\n", (last - x + 256) % 256);//记得换行
last = x;
}
return 0;
}
//严禁抄袭题解,共创和谐洛谷