博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~
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. SDN 第四次上机作业

    1.建立以下拓扑,并连接上ODL控制器. 2.利用ODL下发流表,使得h3在10s内ping不通h1,10s后恢复. 3.借助Postman通过ODL的北向接口下发流表,再利用ODL北向接口查看已下发 ...

  2. JavaScript定时器的工作原理(翻译)

    JavaScript定时器的工作原理(翻译) 标签(空格分隔): JavaScript定时器 最近在看ajax原理的时候,看到了一篇国外的文章,讲解了JavaScript定时器的工作原理,帮助我很好的 ...

  3. -bash: fork: retry: Resource temporarily unavailable;centos6.5

    Last login: Wed Jun 18 14:04:11 2014 from 1.1.1.135 -bash: fork: retry: Resource temporarily unavail ...

  4. WorldWind源码剖析系列:插件类Plugin、插件信息类PluginInfo和插件编译器类PluginCompiler

    插件类Plugin是所有由插件编译器加载的插件子类的抽象父类,提供对插件的轻量级的访问控制功能. 插件信息类PluginInfo用来存储关于某个插件的信息的类,可以理解为对插件类Plugin类的进一步 ...

  5. Waymo在美国推出自动驾驶汽车共享服务

    导读 经过数月的测试和数百万英里的无人驾驶汽车技术开发,Waymo 正式在美国推出了具有商业性质的自动驾驶汽车的共享服务. 该公司的 Waymo One 项目将为客户提供 24 小时自动驾驶汽车服务. ...

  6. java操作数据库的事务支持

    一.需求背景: 我们生活经常遇到一个情况:在购买商品的时候,已经支付的了,那么商品应该处于已购买订单里.而不是付款之后,已购买商品没有. 还有转账的时候,转出方和转入方都需要扣减相应的金额,而不是一方 ...

  7. CentOS中配置Kafka集群

    环境:三台虚拟机Host0,Host1,Host2 Host0:192.168.10.2 Host1:  192.168.10.3 Host2:  192.168.10.4 在三台虚拟机上配置zook ...

  8. 反向路径过滤——reverse path filter

    原文地址:反向路径过滤——reverse path filter 作者:pwp_cu 反向路径过滤——reverse path filter 一.原理先介绍个非对称路由的概念参考<Underst ...

  9. ASP.NET Core MVC中的IActionFilter.OnActionExecuting方法,可以获取Controller的Action方法参数值

    用过ASP.NET Core MVC中IActionFilter拦截器的开发人员,都知道这是一个非常强大的MVC拦截器.最近才发现IActionFilter的OnActionExecuting方法,甚 ...

  10. Jupyter Notebook中让python2和python3内核共存

    自己计算机里面共存了Python2和Python3,ipython作为试探性的REPL解释器使用的频率还是挺高的,分别在2和3下安装完ipython notebook后怎么分别使用这两种内核呢 按照默 ...