結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-02-16 22:26:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 549 bytes |
| コンパイル時間 | 532 ms |
| コンパイル使用メモリ | 62,972 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 07:20:45 |
| 合計ジャッジ時間 | 1,208 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,s,e) for (int i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
int calc(string s) {
if (s.empty())
return 0;
size_t len;
int x = stoi(s,&len);
return x + calc(s.substr(len));
}
int main() {
string s;
cin >> s;
int mx = -1e9;
rep(i,s.size()) {
if (isdigit(s.front()) && isdigit(s.back()))
mx = max(mx,calc(s));
s = s.substr(1) + s.front();
}
cout << mx << endl;
return 0;
}
h_noson