結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-03 16:08:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,495 bytes |
| コンパイル時間 | 687 ms |
| コンパイル使用メモリ | 58,788 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-14 08:27:33 |
| 合計ジャッジ時間 | 3,418 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:76:18: warning: ‘mem1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
76 | s[i+n/2] = mem1;
| ~~~~~~~~~^~~~~~
ソースコード
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/* */
/* 入力開始! */
/* 入力終了! */
int n;
void suuzi(char s[],int i,int& j)
{
for(; j < n/2; j++) {
if(s[i+j] < '0' || '9' < s[i+j]) break;
}
}
int main(void)
{
int i,j,k,l;
char s[25];
int mem1;
int rep = INT_MIN;
cin >> s;
strcat(s,s);
n = strlen(s);
for(i = 0; i < n/2; i++) {
int m = 1;
for(j = 0; j < n/2; j++) {
if(s[i+j] == '+' || s[i+j] == '-') {
if(m == 1) break;
else m = 1;
}
if('0' <= s[i+j] && s[i+j] <= '9') m = 0;
}
/*
cout << endl;
cout << "i = " << i << endl;
cout << "j = " << j << endl;
*/
if(m == 1) continue;
if(j == n/2) {
mem1 = s[i+n/2];
s[i+n/2] = 0;
/*
for(j=0;j<n/2;j++) {
cout << s[i+j];
}
cout << endl;
*/
int ans;
j = 0;
ans = atoi(s+i+j); suuzi(s,i,j);
/*
cout << "ans = " << ans << endl;
cout << "j = " << j << endl;
*/
// s[j] = '+' or '-'
while(j < n/2) {
ans += atoi(s+i+j);
// cout << "atoi(s+i+j) = " << atoi(s+i+j) << endl;
j++;
// '0' <= s[i+j] <= '9'
// cout << "ans = " << ans << endl;
suuzi(s,i,j);
}
if(ans > rep) rep = ans;
}
s[i+n/2] = mem1;
}
cout << rep << endl;
return 0;
}