获赞
296
粉丝
45
关注
0
看过 TA
17
上海交通大学
2017
Java
IP属地:未知
暂未填写个人简介
私信
关注
试卷类别: 服务端开发类试卷 PS: 只过20%... 我的策略是: 有些字符, 比如Z, 只出现在ZERO中, 那么就可以唯一确定 0 (这里讨论的0 是 (index + 8)%10过后的结果 ) 了, 假设出现n个Z, 那么对应的就有n个0, 然后把n个 'Z' 'E' 'R' 'O' 字符 从输入里面删掉, 接下来就不可能出现0了! 同理: Z -> 0 W -> 2 U -> 4 X -> 6 G -> 8 在上面这6个数字的情况都处理完毕之后, ...
牛客66666666号:#include <iostream> #include <vector> #include <string> using namespace std; int main()  { int T; cin>>T; for(int t = 0; t < T; ++t) { string str; cin>>str; int cnt[128] = {0}; for(int i = 0; i < str.length(); ++i) ++cnt[str[i]]; int num[10] = {0}; num[0] = cnt['Z']; num[2] = cnt['W']; num[4] = cnt['U']; num[6] = cnt['X']; num[8] = cnt['G']; num[1] = cnt['O'] - num[0] - num[2] - num[4]; num[3] = cnt['H'] - num[8]; num[5] = cnt['F'] - num[4]; num[7] = cnt['V'] - num[5]; num[9] = cnt['I'] - num[5] - num[6] - num[8]; for(int i = 0, j = 8; i < 10; ++i, j = (j + 1) % 10) for(int k = 0; k < num[j]; ++k) cout<<(j + 2) % 10; cout<<endl; }     return 0; } 思路差不多
投递小米集团等公司10个岗位 >
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客企业服务