博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~
http://www.cnblogs.com/chenxiwenruo/p/6789775.html
特别不喜欢那些随便转载别人的原创文章又不给出链接的
所以不准偷偷复制博主的博客噢~~

水题,就是统计n个数的数位和有多少个不同的,并且输出即可。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
const int maxn =;
int vis[maxn];
int main()
{
int n;
char val[];
memset(vis,,sizeof(vis));
scanf("%d",&n);
int cnt=;
for(int i=;i<n;i++){
scanf("%s",val);
int len=strlen(val);
int sum=;
for(int i=;i<len;i++){
sum+=val[i]-'';
}
if(!vis[sum])
cnt++;
vis[sum]=;
}
printf("%d\n",cnt);
bool first=true;
for(int i=;i<;i++){
if(vis[i]){
if(first){
printf("%d",i);
first=false;
}
else
printf(" %d",i);
}
}
return ;
}

PAT甲题题解-1120. Friend Numbers (20)-水题的更多相关文章

  1. PAT甲题题解-1041. Be Unique (20)-水题

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789189.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  2. PAT甲题题解-1050. String Subtraction (20)-水题

    #include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...

  3. PAT甲题题解-1032. Sharing (25)-链表水题

    #include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...

  4. PAT (Advanced Level) Practice 1120 Friend Numbers (20 分) (set)

    Two integers are called "friend numbers" if they share the same sum of their digits, and t ...

  5. PAT甲题题解-1121. Damn Single (25)-水题

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789787.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  6. PAT甲级 1120. Friend Numbers (20)

    1120. Friend Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Two in ...

  7. PAT 甲级 1023 Have Fun with Numbers (20 分)(permutation是全排列题目没读懂)

    1023 Have Fun with Numbers (20 分)   Notice that the number 123456789 is a 9-digit number consisting ...

  8. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  9. 【专业找水题】状压dp最水题,没有之一

    题目链接 现在代码能力没上升,倒是越来越会找水题了(比例题还水的裸题你值得拥有) 这网站不是针对竞赛的,所以时空限制都很宽松 然后就让我水过去了 对于每个点,包括自己的前m个元素是否取都是一种状态,所 ...

随机推荐

  1. Oracle 导出用户下的所有索引创建语句

    SELECT dbms_lob.substr(dbms_metadata.get_ddl('INDEX', INDEX_NAME))||';'  from dba_indexes where owne ...

  2. 团队作业——Alpha冲刺 12/12

    团队作业--Alpha冲刺 冲刺任务安排 杨光海天 今日任务:自定义保存界面布局以及交互接口函数的实现 明日任务:总结项目中的问题,为什么没能按照预期推进项目 郭剑南 今日任务:继续解决Python编 ...

  3. 详解--从地址栏输入url到页面展现中间都发生了什么?

    这是一个综合性很强的问题,个人理解包含以下七个基本点: 1.在浏览器地址栏输入url并按下回车. 2.浏览器检查当前url是否存在缓存和缓存是否过期. 3.域名解析(DNS解析url对应的ip). 4 ...

  4. Spark项目之电商用户行为分析大数据平台之(十)IDEA项目搭建及工具类介绍

    一.创建Maven项目 创建项目,名称为LogAnalysis 二.常用工具类 2.1 配置管理组建 ConfigurationManager.java import java.io.InputStr ...

  5. MP实战系列(十)之SpringMVC集成SpringFox+Swagger2

    该示例基于之前的实战系列,如果公司框架是使用JDK7以上及其Spring+MyBatis+SpringMVC/Spring+MyBatis Plus+SpringMVC可直接参考该实例. 不过建议最好 ...

  6. Node.js实战(八)之回调函数

    Node.js 异步编程的直接体现就是回调. 异步编程依托于回调来实现,但不能说使用了回调后程序就异步化了. 回调函数在完成任务后就会被调用,Node 使用了大量的回调函数,Node 所有 API 都 ...

  7. jsp泛型支持

    今天在使用idea做练习时,某个jsp页面报错如下: '<>'operator is not allowed for source level below 1.7 出错代码如下: Map& ...

  8. C. Greedy Arkady

    kk people want to split nn candies between them. Each candy should be given to exactly one of them o ...

  9. ansible-playbook如何判断并中断执行

    - fail: msg="Bailing out. this play requires 'bar'"       when: bar is not defined 我的需求是当某 ...

  10. php中经常使用的string函数

    strpos() ---返回字符串在另一字符串中首次出现的位置 strrpos() ---查找字符串在另一字符串中最后出现的位置 strchr()   ===  strstr()    ---找到字符 ...