結果
| 問題 | No.193 筒の数式 |
| コンテスト | |
| ユーザー |
takayuta1999
|
| 提出日時 | 2015-04-26 22:22:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 847 bytes |
| コンパイル時間 | 358 ms |
| コンパイル使用メモリ | 38,964 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 02:57:23 |
| 合計ジャッジ時間 | 995 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:17: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘char (*)[12]’ [-Wformat=]
16 | scanf("%s",&str);
| ~^ ~~~~
| | |
| | char (*)[12]
| char*
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%s",&str);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 12
#define INF 1000000000000LL
using namespace std;
typedef long long int ll;
char str[SIZE];
int main()
{
scanf("%s",&str);
int n=strlen(str);
ll ret=-INF;
for(int i=0;i<n;i++)
{
if(str[i]=='-'||str[i]=='+') continue;
if(str[(i+n-1)%n]=='-'||str[(i+n-1)%n]=='+') continue;
ll calc=0;
int now=i;
while(str[now]!='-'&&str[now]!='+')
{
calc*=10LL;
calc+=str[now]-'0';
now=(now+1)%n;
if(now==i) break;
}
while(now!=i)
{
bool up=str[now]=='+';
now=(now+1)%n;
ll vl=0;
while(str[now]!='-'&&str[now]!='+')
{
vl*=10LL;
vl+=str[now]-'0';
now=(now+1)%n;
if(now==i) break;
}
if(up) calc+=vl;
else calc-=vl;
}
ret=max(ret,calc);
}
printf("%lld\n",ret);
return 0;
}
takayuta1999