結果

問題 No.2203 POWER!!!!!
ユーザー zezerozezero
提出日時 2023-02-03 22:19:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 719 bytes
コンパイル時間 961 ms
コンパイル使用メモリ 102,044 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 18:20:26
合計ジャッジ時間 2,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 7 ms
4,376 KB
testcase_09 AC 16 ms
4,376 KB
testcase_10 AC 25 ms
4,380 KB
testcase_11 AC 37 ms
4,376 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 30 ms
4,380 KB
testcase_14 AC 30 ms
4,376 KB
testcase_15 AC 30 ms
4,380 KB
testcase_16 AC 30 ms
4,376 KB
testcase_17 AC 30 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


ll pow(ll a, ll b){
   ll res = 1LL;
   for (int i = 0; i < b;i++){
      res *= a;
   }
   return res;
}
void solve(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<ll,ll> mp;
  ll ans = 0;
  for (int i = 0; i < n;i++){
   mp[a[i]]++;
  }
  for (int i = 0; i < n;i++){
   for (auto [x,y]:mp){
      ans += pow(a[i],x)*y;
   }
  }
  cout << ans << endl;

  return;
}

  

int main(){
  int tt = 1;
  //cin >> tt;
  while(tt--){
	  solve();
  }
  return 0;
}
0