零点工作室暑假集训(AtCoder--ABC278)

A - Shift

题意:给定一个数 N 和 K 将长度为 N 数组的前 K 项删除后输出后面内容,后面补零!

AC代码:

#include <iostream>

using namespace std;

const int N = 110;

int n, k;
int a[N];

int main()
{
    cin >> n >> k;
    
    if(n <= k)
    {
        for(int i = 1; i <= n; i ++)
        {
            cout << '0' << " ";
        }
        
        return 0;
    }
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
    }
    
    for(int i = k + 1; i <= n; i ++)
    {
        cout << a[i] << " ";
    }
    
    for(int i = 1; i <= k; i ++)
    {
        cout << '0' << " ";
    }
    
    return 0;
}

B - Misjudge the Time

题意:给定H M , A , B :C , D将B和C调换按24小时计时法仍然合法的包括现在的第一个时间

思路:直接暴力枚举即可

#include <iostream>

using namespace std;
 
int h , m;

int main()
{
    cin >> h >> m;
    int a, b, c, d;
    a = h / 10 , b = h % 10 , c = m / 10 , d = m % 10;
    while(a * 10 + c > 23 || b * 10 + d > 59)
    {
        d ++;
        if(d >= 10)
        {
            d %= 10;
            c ++;
        }
        if(c >= 6)
        {    
            c %= 6; 
            b ++;
        }
        if(b >= 10)
        {
            b %= 10;
            a ++;
        }
        if(a == 2 && b >= 4)
        {
            b %= 4;
            a = 0;
        }
            
    }
    cout << a * 10 + b << " " << c * 10 + d << endl;
    return 0; 
}

C - FF

注意到题目的数据范围 , ≤1e9 ! 单纯的二维数组必定 会RE !

既然这样 ,可以使用map来解决问题。(也可以用set来维护)

#include <iostream>
#include <map>

using namespace std;

map<int,map<int ,int > >g;

int n, q;
int a, b, t;

int main()
{
    cin >> n >> q; 
    for(int i = 0; i < q; i ++)
    {
          int a, b, t;
          cin >> t >> a >> b;
          if(t == 1)
          {
              g[a][b] = 1;
        }
        if(t == 2)
        {
            g[a][b] = 0;
        }
        if(t == 3)
        {
            if(g[a][b] == 1 && g[b][a] == 1)
            cout << "Yes" << endl;
            else cout << "No" << endl;
        }
      }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值