반응형
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main( final String[] args ) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String str = br.readLine();
int length = str.length();
int result = 1;
for ( int i = 0; i < (length / 2); i++ ) {
if ( str.charAt(i) != str.charAt(length - (i + 1)) ) {
result = 0;
}
}
bw.append(result + "");
bw.flush();
}
}
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main( final String[] args ) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String str = br.readLine();
StringBuffer sb = new StringBuffer(str);
if ( str.equals(sb.reverse().toString()) ) {
bw.append("1");
bw.flush();
} else {
bw.append("0");
bw.flush();
}
}
}
속도는 같어
반응형
'전공 > Algorithm' 카테고리의 다른 글
[BJ1018] 카이사르 암호 (0) | 2019.12.11 |
---|