Educational Codeforces Round 71 [Rated for Div. 2]

A There Are Two Types Of Burgers

传送门
简单的分类讨论而已

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
const int maxn=1e6+5;
int main(){
    int t;
    cin>>t;
    while(t--){
        int b,p,f;
        cin>>b>>p>>f;
        int h,c;
        cin>>h>>c;
        int con=b/2;
        if(con<=min(p,f)){//面包少的话
            if(h>=c){//牛肉贵,买牛肉
                printf("%d\n",con*h);
            }else{
                printf("%d\n",con*c);
            }
        }else{//面包够的话
            if(h>=c){//牛肉贵,先买牛肉
                if(con>=p){//大于牛肉的数,牛肉全卖加鸡肉
                    if(con>=(p+f)){
                        printf("%d\n",h*p+f*c);
                    }else{
                        printf("%d\n",h*p+(con-p)*c);
                        //printf("aa\n");
                    }
                }else{//全卖牛肉
                    printf("%d\n",con*h);
                    //printf("aa\n");
                }
            }else{//先卖鸡肉
                if(con>=f){
                    if(con>=(p+f)){
                        printf("%d\n",c*f+p*h);
                        //printf("aaa\n");
                    }else{
                        printf("%d\n",c*f+(con-f)*h);
                        //printf("aa\n");
                    }
                }else{//全卖鸡肉
                    printf("%d\n",con*c);
                    //printf("aa\n");
                }
            }

        }
    }
    return 0;
}

B Square Filling

传送门
从左上角到右下角枚举过去就行了,简单题

#include <iostream>
#include <cstdio>
using namespace std;
int n,m;
int a[55][55];
int c[55][55];
int flag=1;
int times=0;
struct node{
    int x,y;
}how[2505];
int check(){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(c[i][j]!=a[i][j]){
                flag=0;
                return 0;
            }
        }
    }
    flag=1;
    return 1;
}
void change(int x,int y){
    a[x][y]=1;
    if(x+1<=n&&y<=m)a[x+1][y]=1;
    if(x<=n&&y+1<=m)a[x][y+1]=1;
    if(x+1<=n&&y+1<=m)a[x+1][y+1]=1;
}
int main(){
    cin>>n>>m;
    int sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%d",&c[i][j]);
            if(c[i][j]==0)sum++;
        }
    }

    //while(1){
        int over=check();
        for(int i=1;i<=n-1;i++){
            for(int j=1;j<=m-1;j++){
                if(c[i][j]==1&&c[i][j+1]&&c[i+1][j]&&c[i+1][j+1]){
                    change(i,j);
                    how[times].x=i,how[times++].y=j;
                    over=check();
                }
                if(over)break;
            }
            if(over)break;
        }
        //if(over)break;
    //}

    if(flag){
        if(sum==n*m){
            printf("0\n");//都是0,不需要变
        }else{
            printf("%d\n",times);
            for(int i=0;i<times;i++){
                printf("%d %d\n",how[i].x,how[i].y);
            }
        }
    }else{//不存在这种情况
        printf("-1\n");
    }
    return 0;
}

转载于:https://www.cnblogs.com/Emcikem/p/11400407.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值