【CodeForces 672B】Different is Good
2016-07-31 16:28
288 查看
题
字符串所有子串要不同。求修改最少多少个字符。
因为只能是26个字母,显然大于26的不可能有答案,其它情况ans+=u[i]-1;u[i]是字母出现的次数。
字符串所有子串要不同。求修改最少多少个字符。
因为只能是26个字母,显然大于26的不可能有答案,其它情况ans+=u[i]-1;u[i]是字母出现的次数。
#include<cstdio> char s; int n,u[30],ans; int main(){ scanf("%d ",&n); for(int i=0;i<n;i++){ scanf("%c ",&s); u[s-'a']++; } if(n>26)printf("-1"); else{ for(int i=0;i<26;i++) if(u[i])ans+=u[i]-1; printf("%d",ans); } }
相关文章推荐
- CodeForces-672B-Different is Good
- [CodeForces]-672B-Different is Good
- codeforces 672B B. Different is Good(水题)
- B. Different is Good
- Codeforces Round #352 (Div. 2)-B. Different is Good(模拟)
- Codeforces Round #352 (Div. 2) B. Different is Good
- BZOJ 1419 Red is good 期望DP
- Error: An App ID with identifier "*****" is not avaliable. Please enter a different string.
- CodeForces - 757C - Felicity is Coming!(思维)
- why sleep is good 4 ur apps padding oracle
- 一份好的简历应该是这样的(This Is What A GOOD Resume Should Look Like)
- A good programming is 99% sweat and 1% coffee!
- “gjw” is of a model that is not supported by this version of Xcode. Please use a different device.
- Codeforces 749B-Parallelogram is Back
- 6sigma is a good issue improved
- VS2010 Debugger --The source file is different from when the module was built
- Here is a good blog spot for Android
- What is the different between a Cluster and MPP supercomputer architecture?
- CodeForces 131C The World is a Theatre 组合数
- What is different between ClassLoader.getResourceAsStream() and Class.getResourceAsStream()?