ICPC Central Russia Regional Contest (CRRC 19)

本文详细解析了ICPC Central Russia Regional Contest (CRRC 19)的部分题目,包括电阻并联求解、幂运算的巧妙应用以及涉及几何的挑战,如小时glass问题和三角形询问。通过二分查找、模拟和集合游戏策略,阐述了解题思路和技巧。
摘要由CSDN通过智能技术生成

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 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值