Problem Links:
uva10878,Problem:
Time Limit: 1 second
"Machines take me by surprise with great frequency." |
Your boss has just unearthed a roll of old computer tapes. The tapes have holes in them and might contain some sort of useful information. It falls to you to figure out what is written on them.
Input
The input will contain one tape.
The input will contain one tape.
Output
Output the message that is written on the tape.
Output the message that is written on the tape.
Sample Input | Sample Output |
___________ | o . o| | o . | | ooo . o| | ooo .o o| | oo o. o| | oo . oo| | oo o. oo| | o . | | oo . o | | ooo . o | | oo o.ooo| | ooo .ooo| | oo o.oo | | o . | | oo .oo | | oo o.ooo| | oooo. | | o . | | oo o. o | | ooo .o o| | oo o.o o| | ooo . | | ooo . oo| | o . | | oo o.ooo| | ooo .oo | | oo .o o| | ooo . o | | o . | | ooo .o | | oo o. | | oo .o o| | o . | | oo o.o | | oo . o| | oooo. o | | oooo. o| | o . | | oo .o | | oo o.ooo| | oo .ooo| | o o.oo | | o. o | ___________ | A quick brown fox jumps over the lazy dog. |
Problemsetter: Igor Naverniouk
Special thanks: BSD games ppt.
Solution:
Nothing is explained in the problem. Actually each letter is represented by its ASCII value. o means 1 and space means 0.
Source Code:
//Sun Apr 24 00:32:14 CDT 2011#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(int argc, char* argv[]) {
// freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
string s;
while (getline(cin, s, '\n')) {
if (s[0] != '|')
continue;
int sum = 0;
for (int i = 2; i < s.size() - 1; i++) {
if (s[i] == '.')
continue;
sum *= 2;
sum += (s[i] == 'o' ? 1 : 0);
}
cout << char(sum);
}
// fclose(stdin);
//fclose(stdout);
return 0;
}
No comments :
Post a Comment