0173
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
string c;
int am, pm;
while (cin >> c) {
scanf("%d%d",&am,&pm);
int resp = am + pm;
int price = am * 200 + pm * 300;
cout << c;
printf(" %d %d\n", resp, price);
}
}
0174
#include <iostream>
using namespace std;
int main() {
string set;
while (cin >> set) {
if (set == "0") break;
int a = 0, b = 0;
for (int i=1; i<set.length(); i++) {
if (set[i] == 'A') a++;
if (set[i] == 'B') b++;
}
if (a > b) a++;
else if (a < b) b++;
cout << a << " " << b << endl;
}
}
0175
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
while (scanf("%d", &n) && n != -1) {
string res = "";
if (n == 0) {
printf("0\n");
continue;
}
while (n > 0) {
res += (n % 4 + '0');
n /= 4;
}
reverse(res.begin(), res.end());
cout << res << endl;
}
}
0176
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
string color[] = {"black", "blue", "lime", "aqua",
"red", "fuchsia", "yellow", "white"};
int nums[][3] = {{0,0,0}, {0,0,255}, {0,255,0}, {0,255,255},
{255,0,0}, {255,0,255}, {255,255,0}, {255,255,255}};
int convert(string str) {
int res = 0;
if ('0'<=str[0]&&str[0]<='9') {
res += (str[0]-'0') * 16;
} else if ('a'<=str[0]&&str[0]<='f') {
res += (str[0]-'a'+10) * 16;
}
if ('0'<=str[1]&&str[1]<='9') {
res += (str[1]-'0');
} else if ('a'<=str[1]&&str[1]<='f') {
res += (str[1]-'a'+10);
}
return res;
}
int main() {
string str;
while (cin >> str) {
if (str == "0") break;
double d = 10000000.0;
string res;
int r = convert(str.substr(1,2)), g = convert(str.substr(3,2)), b = convert(str.substr(5,2));
for (int i=0; i<8; i++) {
double tmp = sqrt(pow(r-nums[i][0], 2)+pow(g-nums[i][1], 2)+pow(b-nums[i][2], 2));
if (tmp < d) {
d = tmp;
res = color[i];
}
}
cout << res << endl;
}
}