結果
| 問題 | No.193 筒の数式 |
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2015-06-09 01:51:54 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 1,000 ms |
| コード長 | 1,295 bytes |
| 記録 | |
| コンパイル時間 | 2,966 ms |
| コンパイル使用メモリ | 88,144 KB |
| 実行使用メモリ | 41,200 KB |
| 最終ジャッジ日時 | 2024-07-06 14:58:04 |
| 合計ジャッジ時間 | 4,822 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
final String S = sc.next();
int max = Integer.MIN_VALUE;
for(int slide = 0; slide < S.length(); slide++){
final String rotated = S.substring(slide) + S.substring(0, slide);
if(rotated.charAt(0) == '+' || rotated.charAt(0) == '-'){
continue;
}else if(rotated.charAt(rotated.length() - 1) == '+' || rotated.charAt(rotated.length() - 1) == '-'){
continue;
}
char[] in = rotated.toCharArray();
int current = 0, cur_pos = 0;
while(cur_pos < in.length && '0' <= in[cur_pos] && in[cur_pos] <= '9'){
current *= 10;
current += Character.getNumericValue(in[cur_pos++]);
}
while(cur_pos < in.length){
final int sign = in[cur_pos] == '+' ? 1 : -1;
cur_pos++;
int snd = 0;
while(cur_pos < in.length && '0' <= in[cur_pos] && in[cur_pos] <= '9'){
snd *= 10;
snd += Character.getNumericValue(in[cur_pos++]);
}
current += sign * snd;
}
max = Math.max(max, current);
}
System.out.println(max);
}
}
uafr_cs