牛客小白月赛 78

比赛地址 : 

牛客小白月赛78

A.几何糕手

题目链接 : 

几何糕手

题面 : 

思路 : 

数学模拟题;

最大面积就是在a与b成一条直线的情况下;

so : 输出pi * (a+b) * (a+b)即可

注意 : 注意精度!!!

代码 : 

#include<iostream>
#include<algorithm>
using namespace std;
const double pi = 3.141592653589793238462643383279502884197169399;
int main(){
    int a,b;
    cin>>a>>b;
    double ans = 1.0 * pi * ((a+b)*(a+b)) ;
    printf("%.10f",ans);
    return 0;
}

B.国际裁判带师

原题链接 : 

国际裁判带师

题面 : 

思路 : 

数据量小,模拟即可;

具体模拟过程请看代码 : 

代码 : 

#include<iostream>
#include<algorithm>
#include<cstring>
typedef long long LL;
using namespace std;
int cnt(string t){
    int cnt = 0;
    for(char c : t) if(c=='0') cnt ++;
    return cnt;
}
string tran(string &t,char c){
    if(c=='a'){
        if(t[1]-'0' >=0 && t[1]-'0'<= 8) t[1]++;
        else{
            t[0]++;
            t[1] = '0';
        }
    }else {
        if(t[3]=='9'){
            t[2]++;
            t[3]='0';
        }else t[3]++;
    }
    return t;
}

int main(){
    string s ;
    LL ans;
    cin>>s;
    string t = "0000";
    for(char c : s){
        tran(t,c);
        ans += cnt(t);
    }
    cout << ans << endl;
}

C.第K小表示数

链接 : 

第K小表示数

思路 : 

用一个set集合来实现去重和排序,然后模拟加入的过程;

代码 : 

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
    ll k, a, b, l;
    cin>>k>>a>>b;
    set<ll> s;
    s.insert(a);
    s.insert(b);
    while (k--) {
        l = *s.begin();
        s.erase(s.begin());
        s.insert(l+a);
        s.insert(l+b);
    }
    cout<<(l);
    return 0;
}

// 2 3 4 5 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值