【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\n",need); }else puts("impossible"); } return 0; }