結果
| 問題 |
No.222 引き算と足し算
|
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-11-16 04:24:26 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 935 bytes |
| コンパイル時間 | 2,383 ms |
| コンパイル使用メモリ | 77,140 KB |
| 実行使用メモリ | 41,564 KB |
| 最終ジャッジ日時 | 2024-11-26 02:06:30 |
| 合計ジャッジ時間 | 6,961 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 1 RE * 5 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String xopy = sc.next();
int z = ind(xopy);
int x = Integer.parseInt( xopy.substring(0,z) );
int y = Integer.parseInt( xopy.substring(z+1) );
String op = xopy.substring(z,z+1);
int r =0;
if( op.equals("+") ){
r = x-y;
}else{
r = x+y;
}
System.out.println(r);
}
static int ind(String S){
int n = S.indexOf("+");
if(n==0){
S=S.substring(1);
n=S.indexOf("+")+1;
}
if(n<=0){
n=Integer.MAX_VALUE;
}
int m = S.indexOf("-");
if(m==0){
S=S.substring(1);
m=S.indexOf("-")+1;
}
if(m<=0){
m=Integer.MAX_VALUE;
}
return Math.min(n,m);
}
}
kohaku_kohaku