【LGR-067】洛谷 1 月月赛 II & CSGRound 3 Div.2

1/2

//在我目前能力范围内的写完了,拿到了该有的分数。

P6013 [CSGRound3]压岁钱

  • 注意数据范围 int 会超,改long long
  • 解封的钱在任何一件时间发生前都有可能解封。
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string.h>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define lowbit(i)((i)&(-i))
using namespace std;
typedef long long ll;
const int MAX=1000010;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
const int SQR=633;
ll book[MAX];
int main()
{
    int m;
    ll ans=0,sum=0;
    memset(book,0,sizeof(book));
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
    {
        int t;
        ll a,b;
        scanf("%d",&t);
        if(t==1||t==2)
            scanf("%lld",&a);//存a元,花a元
        else if(t==3)
        {
            scanf("%lld%lld",&a,&b);//存a元,b天时解封
        }
        sum+=book[i];
        if(t==1)
            sum+=a;
        else if(t==2)
        {
            if(sum<a)
                ans++;
            else
                sum-=a;
        }
        else if(t==3)
        {
                sum-=a;
                book[b]+=a;
        }
    }
    cout<<ans<<endl;
    return 0;
}

P6014 [CSGRound3]斗牛

  • 先求和,然后枚举其中的任意两张牌,减去这两张牌的和后,能否整除10.
  • 枚举过程:枚举[1,10]
    两张牌不同,且数量大于等于1
    两张牌相同,该牌数量大于等于2
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string.h>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#define lowbit(i)((i)&(-i))
using namespace std;
typedef long long ll;
const int MAX=1000001;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
const int SQR=633;
int x[MAX];
int book[10];
int main()
{
   int n,sum=0;
   scanf("%d",&n);
   for(int i=0;i<n;i++)
   {
       scanf("%d",&x[i]);
       sum+=x[i];
       book[x[i]]++;
   }
   int flag=1,maxn=0;
   for(int i=1;i<=10;i++)
   {
       for(int j=i+1;j<=10;j++)
       {
           if(book[i]>=1&&book[j]>=1)
           {
               int k=i+j;
              if((sum-k)%10==0)
              {
               flag=0;
               if(k%10!=0)
               maxn=max(k%10,maxn);
               else
               maxn=10;
              }
           }

       }
   }

       for(int j=1;j<=10;j++)
       {
           if(book[j]>=2)
           {
               int k=2*j;
              if((sum-k)%10==0)
              {
               flag=0;
               if(k%10!=0)
               maxn=max(k%10,maxn);
               else
               maxn=10;
              }
           }

       }
   if(flag==1)
    cout<<"0"<<endl;
   else
    cout<<maxn<<endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值