1056. 组合数的和(15)
时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B
判题程序 Standard 作者 CHEN, Yue
给定N个非0的个位数字,用其中任意2个数字都可以组合成1个2位的数字。要求所有可能组合出来的2位数字的和。例如给定2、5、8,则可以组合出:25、28、52、58、82、85,它们的和为330。
输入格式:
输入在一行中先给出N(N大于1小于10),随后是N个不同的非0个位数字。数字间以空格分隔。
输出格式:
输出所有可能组合出来的2位数字的和。
输入样例:
3 2 8 5
输出样例:
330
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <vector>
#include <string>
#include <cfloat>
#include <queue>
#include <map>
#define INF INT32_MAX
using namespace std;
const int MaxN = 11;
int main()
{
#ifdef _DEBUG
freopen("data.txt", "r+", stdin);
#endif // _DEBUG
std::ios::sync_with_stdio(false);
int data[MaxN],n;
cin >> n;
for (int i = 0; i < n; ++i)cin >> data[i];
int res = 0;
for (int i = 0; i < n; ++i)
{
for (int k = 0; k < n; ++k)
{
if (i != k) res += data[i] * 10 + data[k];
}
}
cout << res;
return 0;
}