128

题目真难理解,看了网上的翻译才懂的,具体实现其实并不难,
//============================================================================
// Name        : 128.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

string s;
long long ans, t;

int main() {
	while(1){
		getline(cin, s);
		if(s.length() == 0)
			cout << "00 00" << endl;
		else if(s == "#") break;
		else{
			t = 0;
			for(int i = 0;i < s.length();i++){
				t = ((t << 8)+s[i])%34943;
			}
			t = (t << 16)%34943;
			ans = 34943-t;
			printf("%02X ", ans>>8);
			printf("%02X\n", ans-((ans>>8)<<8));
		}
	}
	return 0;
}
posted @ 2011-05-24 21:21  KOKO's  阅读(97)  评论(0编辑  收藏  举报