上海iai2020年4月月赛丙组

2020年4月月赛

竞选班长

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fst ios::sync_with_stdio();cin.tie(0);cout.tie(0);
const int N = 1e6+500;
const int mod = 10000;
​
int main()
{
    fst
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a>=90&&b>=90||a>=90&&c>=90||b>=90&&c>=90)&&d>=85)
    {
        cout<<"Qualified";
    }
    else cout<<"Not qualified";
    return 0;
}

永恒的生命游戏

#include <bits/stdc++.h>
using namespace std;
const int N = 107;
char s[N][N];
int n,m;
bool check(int x,int y)
{
    int ans=0;
    for(int i=-1;i<=1;i++)
    {
        for(int j=-1;j<=1;j++)
        {
            if(i==0&&j==0)continue;
            if(i+x>=1&&i+x<=n&&j+y>=1&&j+y<=m&&s[i+x][j+y]=='*')ans++;      
        }
    }
    return ans==2||ans==3;
}
int main()
{
    
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)cin>>s[i][j];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i][j]=='*')
            {
                if(!check(i,j))
                {
                    cout<<"Other";
                    return 0;
                }
            }
        }
    }
    cout<<"Still life";
    return 0;
}

调配问题(一)

#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, a[maxn];
long long s, ans;
int main() {
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        s += a[i];
        ans += abs(s);
    }
    cout << ans << endl;
    return 0;
}

数字验证

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fst ios::sync_with_stdio();cin.tie(0);cout.tie(0);
const int N = 1e6+500;
const int mod = 10000;
int f[N];
int main()
{
    fst
    string s;
    cin>>s;
    for(auto i:s)
    {
        if(i=='.'||i=='+'||i=='-'||i>='0'&&i<='9')f[i]++;
        else 
        {
            cout<<"Invalid";
            return 0;
        }
    }
    if(f['+']+f['-']>1)
    {
        cout<<"Invalid";
        return 0;
    }
    if(f['+']+f['-']==1&&s[0]!='-'&&s[0]!='+')
    {
        cout<<"Invalid";
        return 0;
    }
    if(f['.']>1)
    {
        cout<<"Invalid";
        return 0;
    }
    if(s.size()-f['.']-f['+']-f['-']==0)
    {
        cout<<"Invalid";
        return 0;
    }
    cout<<"Valid";
    return 0;
}

吃苹果

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fst ios::sync_with_stdio();cin.tie(0);cout.tie(0);
const int N = 1e6+500;
const int mod = 10000;
map<int,int>mp;
set<int>st; 
int main()
{
    fst
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        x++;
        st.insert(x);
        mp[x]++;
    }
    int ans=0;
    for(auto i:st)
    {
        ans+=min(i-ans,mp[i]);
    }
    cout<<ans;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值