• 【AIM Tech Round 4 (Div. 2) A】Diversity


    【链接】http://codeforces.com/contest/844/problem/A


    【题意】


    大水题

    【题解】


    看看不同的个数num是不是小于k,小于k,看看len-num够不够补的

    【错的次数】


    0

    【反思】


    貌似那种判断条件比较多的题都容易hack啊

    【代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define ms(x,y) memset(x,y,sizeof x)
    #define ri(x) scanf("%d",&x)
    #define rl(x) scanf("%lld",&x)
    #define rs(x) scanf("%s",x)
    #define oi(x) printf("%d",x)
    #define ol(x) printf("%lld",x)
    #define oc putchar(' ')
    #define os(x) printf(x)
    #define all(x) x.begin(),x.end()
    #define Open() freopen("F:\rush.txt","r",stdin)
    #define Close() ios::sync_with_stdio(0)
    
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    const int N = 1e3;
    
    
    int a[400];
    char s[N+10];
    
    
    int main(){
        //Open();
        //Close();
        rs(s);
        int len = strlen(s),num = 0;
        int k;
        ri(k);
        rep1(i,0,len-1){
            if (a[s[i]]==0) num++;
            a[s[i]]++;
        }
        if (num >= k){
            puts("0");
        }else{
            int need = k-num;
            if (need <= len-num){
                printf("%d
    ",need);
            }else
                puts("impossible");
        }
        return 0;
    }
    


  • 相关阅读:
    python调用函数实现数据的增删改查(1)
    VA Code编写html(1)
    python 跑服务器,访问自己制作的简单页面
    python调用函数实现数据的增删改查(2)
    VS Code编写html(2)
    python编写简单的html登陆页面(4)
    python编写简单的html登陆页面(1)
    虚拟机端口映射!
    VIM 主题管理
    Vim 窗口管理插件
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626084.html
Copyright © 2020-2023  润新知