結果
| 問題 |
No.289 数字を全て足そう
|
| コンテスト | |
| ユーザー |
kaito_tateyama
|
| 提出日時 | 2017-08-12 09:32:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 685 bytes |
| コンパイル時間 | 583 ms |
| コンパイル使用メモリ | 75,648 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 04:42:40 |
| 合計ジャッジ時間 | 1,376 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
//---------------------------
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
string s;cin>>s;
int t = s.size();
vector<int> v;//string各文字のAscii
for (int i = 0; i < t; i++) {
char c = s[i];
v.push_back(c);
}
int cnt[11] = {};
REP(i,9){
cnt[i+1] = count(v.begin(),v.end(),49+i);
}
int ans = 0;
REP(i,9){
ans += (i+1) * cnt[i + 1];
}
P(ans);
return 0;
}
kaito_tateyama