fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include <bits/stdc++.h>
  4. #include<vector>
  5. #include<string>
  6.  
  7. int f(int a,int b)
  8. {
  9. string str1 = to_string(a);
  10. string str2 = to_string(b);
  11. string res = str1+str2;
  12. //cout<<stoi(res)<<'\n';
  13. return stoi(res);
  14. }
  15.  
  16. int main() {
  17. // your code goes here
  18. int n;
  19. cin>>n;
  20. vector<int>arr(n);
  21. int i=0;
  22. while(i<n)
  23. {
  24. cin>>arr[i];
  25. i++;
  26. }
  27.  
  28. int sum=0;
  29. for(int i=0;i<n;i++)
  30. {
  31. for(int j=0;j<n;j++)
  32. {
  33. sum+=f(arr[i],arr[j]);
  34. }
  35. }
  36. cout<<sum;
  37.  
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 5284KB
stdin
3
1 2 3
stdout
198