给定 N 个非 0 的个位数字,用其中任意 2 个数字都可以组合成 1 个 2 位的数字。要求所有可能组合出来的 2 位数字的和。例如给定 2、5、8,则可以组合出:25、28、52、58、82、85,它们的和为330。

输入格式:

输入在一行中先给出 N(1 < N < 10),随后给出 N 个不同的非 0 个位数字。数字间以空格分隔。

输出格式:

输出所有可能组合出来的2位数字的和。

输入样例:

3 2 8 5

输出样例:

330
 #include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
int n;
int a[];
int main()
{
int n;
while(cin>>n){
for(int i=;i<n;i++){
cin>>a[i];
}
int sum=;
for(int i=;i<n;i++){
for(int j=;j<n;j++){
if(i!=j){
//cout<<a[i]+10*a[j]<<endl;
sum+=a[i]+*a[j];
}
}
}
cout<<sum<<endl;
}
return ;
}

PAT (Basic Level) Practice (中文)1056 组合数的和 (15 分)的更多相关文章

  1. PAT (Basic Level) Practice (中文)1078 字符串压缩与解压 (20 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1078 字符串压缩与解压 (20 分) 凌宸1642 题目描述: 文本压缩有很多种方法,这里我们只考虑最简单的一种:把由相同字符组成的一 ...

  2. PAT (Basic Level) Practice (中文)1070 结绳 (25 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1070 结绳 (25 分) 凌宸1642 题目描述 给定一段一段的绳子,你需要把它们串成一条绳.每次串连的时候,是把两段绳子对折,再如下 ...

  3. PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642 题目描述: "单身狗"是中文对于单身人士的一种爱称.本题请你从上万人的大 ...

  4. PAT (Basic Level) Practice (中文)1055 集体照 (25 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1055 集体照 (25 分) 凌宸1642 题目描述: 拍集体照时队形很重要,这里对给定的 N 个人 K 排的队形设计排队规则如下: 每 ...

  5. PAT (Basic Level) Practice (中文)1054 求平均值 (20 分) 凌宸1642

    PAT (Basic Level) Practice (中文)1054 求平均值 (20 分) 题目描述 本题的基本要求非常简单:给定 N 个实数,计算它们的平均值.但复杂的是有些输入数据可能是非法的 ...

  6. PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) 凌宸1642

    PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) 目录 PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) ...

  7. PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642 题目描述: Given any string of N (≥5) ...

  8. PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642 题目描述: Notice that the number ...

  9. PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642

    PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642 题目描述: This time, you are suppos ...

  10. PAT乙级:1056 组合数的和 (15分)

    PAT乙级:1056 组合数的和 (15分) 给定 N 个非 0 的个位数字,用其中任意 2 个数字都可以组合成 1 个 2 位的数字.要求所有可能组合出来的 2 位数字的和.例如给定 2.5.8,则 ...

随机推荐

  1. python中调用函数时,参数顺序与参数赋值问题

    设置类和函数如下:class MM(): def ff(self,url(1),method(2),data=None(3),cookie=None(4)): if method.lower()==& ...

  2. python OpenCV安装

    linux系统 yum install -y libSM.x86_64 libXext.x86_64 libXrender.x86_64 pip install numpy Matplotlib pi ...

  3. [Linux-CentOS7]yum清华源CentOS7

    shell直接运行 cat > 01.yumrepo.sh << 'EOF' # 创建备份路径 mkdir -p /etc/yum.repos.d/repo.bak/ # 备份源 m ...

  4. 我说我了解集合类,面试官竟然问我为啥HashMap的负载因子不设置成1!?

    在Java基础中,集合类是很关键的一块知识点,也是日常开发的时候经常会用到的.比如List.Map这些在代码中也是很常见的. 个人认为,关于HashMap的实现,JDK的工程师其实是做了很多优化的,要 ...

  5. 404 not found Webshell

    404 not found Webshell 克隆或下载项目: git clone https://github.com/CosasDePuma/SecurityNotFound.git Securi ...

  6. macos常用命令备查

    常用命令 open . : 命令行打开文件夹 文件编辑 ps: 从一般模式进编辑模式,只需按i.I.a.A.o.O.r和R中某个键即可.当进入编辑模式时,在屏幕尾部会显示INSERT或REPLACE字 ...

  7. Linux系统WEB服务之Nginx基础入门

    一.Nginxi简介 Nginx是什么?它是一个开源.高性能的WEB服务器软件和代理服务器软件,由俄罗斯人Igor Sysoev 开发实现.它的功能主要分三类,第一是它作为一个WEB服务软件使用:第二 ...

  8. File类和枚举

    java.io.File类:文件和目录路径名的抽象表示形式 File类常见构造方法: File(String pathname):通过将给定路径名字符串转换为抽象路径名来创建一个新 File 实例. ...

  9. codewars--js--Convert all the cases!

    问题描述: In this kata, you will make a function that converts between camelCase, snake_case, and kebab- ...

  10. JS-重写内置的call、apply、bind

    首先看call和apply,第一个参数就是改变的this指向,写谁就是谁,如果是非严格模式下,传递null或undefined指向的也是window,二者唯一的区别是执行函数时,传递的参数方式不同,c ...