华为杯中国地质大学(武汉)第十七届ICPC程序设计大赛暨华中地区部分高校第十五届ICPC邀请赛

比赛传送门


A-Alice的难题

题解传送门

B-卡牌对战游戏

题解传送门

C-HW的糖果俱乐部(签到)

考虑:

  • 奇+奇=偶
  • 偶+偶=偶

因此偶数可以任选,但是奇数必须保证偶数个,因此先选出所有偶数接着对奇数排序,选尽量大的偶数个即可

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <cstdio>
#include <string>
#include <bitset>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ins insert
#define lowbit(x) (x&(-x))
#define mkp(x,y) make_pair(x,y)
#define mem(a,x) memset(a,x,sizeof a);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps=1e-8;
const double pi=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=1e18;
const int Mod=1e9+7;
const int maxn=2e5+10;

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    ll sum=0;
    vector<int> res;
    for(int i=1,x;i<=n;i++){
        cin>>x;
        if(x&1) res.push_back(x);
        else sum+=x;
    }
    sort(res.begin(),res.end());
    int k=res.size();
    if(k&1){
        for(int i=1;i<k;i++) sum+=res[i];
    }else{
        for(int i=0;i<k;i++) sum+=res[i];
    }
    cout<<sum<<endl;
    return 0;
}
E-有趣的圆柱体(暴力)

因为有偶数个点,而且上下两个圆平面中心连线一定为某坐标轴,因此该中线将点的该轴坐标分为两部分,那么我们枚举三种坐标找到该轴

最后只需求出一个正多边形上某点到其他点最大距离为上下底面半径(下面好像有点问题,我也看不太懂了)

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <cstdio>
#include <string>
#include <bitset>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ins insert
#define lowbit(x) (x&(-x))
#define mkp(x,y) make_pair(x,y)
#define mem(a,x) memset(a,x,sizeof a);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps=1e-8;
const double pi=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=1e18;
const int Mod=1e9+7;
const int maxn=2e5+10;

int t,n;
double h1,h2;
double x[105],y[105],z[105];

inline int dcmp(double d){
    if(fabs(d)<eps) return 0;
    return d>0?1:-1;
}

bool check(double *d){
    for(int i=1;i<=2*n;i++){
        int cnt=0;
        for(int j=1;j<=2*n;j++)
            if(dcmp(d[j]-d[i])==0) cnt++;
        if(cnt==n){
            h1=d[i];
            for(int j=1;j<=2*n;j++)
                if(d[j]!=d[i]){
                    h2=d[j];
                    break;
                }
            return 1;
        }
    }
    return 0;
}

double dis(double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        for(int i=1;i<=2*n;i++)
            scanf("%lf%lf%lf",&x[i],&y[i],&z[i]);
        if(check(x)){
            double h=fabs(h1-h2);
            double r=0.0;
            for(int i=1;i<=2*n;i++)
                r=max(r,dis(y[1],z[1],y[i],z[i]));
            r/=2.0;
            double v=pi*r*r*h;
            printf("%.6f\n",v);
        }else if(check(y)){
            double h=fabs(h1-h2);
            double r=0.0;
            for(int i=1;i<=2*n;i++)
                r=max(r,dis(x[1],z[1],x[i],z[i]));
            r/=2.0;
            double v=pi*r*r*h;
            printf("%.6f\n",v);
        }else if(check(z)){
            double h=fabs(h1-h2);
            double r=0.0;
            for(int i=1;i<=2*n;i++)
                r=max(r,dis(x[1],y[1],x[i],y[i]));
            r/=2.0;
            double v=pi*r*r*h;
            printf("%.6f\n",v);
        }
    }
    return 0;
}
G-字符串解压(栈)

经典题,一般是用栈来做的,但是这个字符串必须保证顺序,那么我们用栈的思想,维护n个队列也行

#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <cstdio>
#include <string>
#include <bitset>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ins insert
#define lowbit(x) (x&(-x))
#define mkp(x,y) make_pair(x,y)
#define mem(a,x) memset(a,x,sizeof a);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> P;
const double eps=1e-8;
const double pi=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=1e18;
const int Mod=1e9+7;
const int maxn=2e5+10;

queue<string> s[205];
int a[maxn];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string str;
    while(cin>>str){
        int x=0;
        for(int i=0;i<str.size();i++){
            if(str[i]>='0' && str[i]<='9'){
                a[++x]=str[i]-'0';
                i++;
            }else if(isalpha(str[i])){
                string res="";
                res+=str[i];
                s[x].push(res);
            }else if(str[i]==']'){
                string res="";
                while(s[x].size()){
                    res+=s[x].front();
                    s[x].pop();
                }
                string ans="";
                for(int j=1;j<=a[x];j++) ans+=res;
                x--;
                s[x].push(ans);
            }
        }
        string ans="";
        while(s[0].size()){
            ans+=s[0].front();
            s[0].pop();
        }
        cout<<ans<<endl;
    }
    return 0;
}
H-和平精英

题解传送门

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值