ICPC Central Russia Regional Contest (CRRC 19)
文章目录
A. Green tea
签到题
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
typedef long long LL;
int a, b;
int main() {
cin >> a >> b;
int res1, res2;
int minn = 0x3f3f3f3f;
for (int i = 0; i <= 1000; i++) {
for (int j = 0; j <= 1000; j++) {
if(i*a+j*b==80*(i+j)&&((i+j)!=0)){
if(i+j<minn){
res1 = i, res2 = j;
minn = i + j;
}
}
}
}
cout << res1 << ' ' << res2 << endl;
return 0;
}
B. Mysterious Resistors
大意:
给出k组串联的电阻,每组电阻都是 r i r_i ri和R并联,现在给出k个 r i r_i ri,以及总电阻,求R
思路:
因为有单调性,所以直接二分去找即可
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int const MAXN = 2e5 + 10;
int n;
double m;
double r[MAXN];
bool check(double mid) {
double sum = 0;
for (int i = 1; i <= n; i++) {
sum += r[i] / (1.0 + r[i] / mid);
}
return sum > m;
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> r[i];
}
double l = 0, r = 1e5;
while (r - l > 1e-8) {
double mid = (l + r) / 2;
if (check(mid))
r = mid;
else
l = mid;
}
printf("%.8lf\n", l);
return 0;
}
C. Emoticons
大模拟。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int const MAXN = 2e5 + 10;
int n, m, T;
map<char, int> num;
unordered_map<char, string> mp;
vector<char> f;
int main() {
string s;
cin >> s;
mp['\\'] = ":-\\";
f.push_back('\\');
mp['P'] = ":-P";
f.push_back('P');
mp['D'] = ":D";
f.push_back('D');
mp['C'] = ":C";
f.push_back('C');
mp['8'] = "8-0";
f.push_back('8');
mp['E'] = ":-E";
f.push_back('E');
mp['%'] = "%0";
f.push_back('%');
mp['X'] = ":-X";
f.push_back('X');
mp['~'] = ":~(";
f.push_back('~');
mp['['] = "[:|||:]";
f.push_back('[');
mp['0'] = ":-0";
f.push_back('0');
mp['|'] = ":-|";
f.push_back('|');
for