結果
問題 | No.273 回文分解 |
ユーザー |
![]() |
提出日時 | 2016-05-11 23:44:41 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 866 bytes |
コンパイル時間 | 2,166 ms |
コンパイル使用メモリ | 74,676 KB |
実行使用メモリ | 50,440 KB |
最終ジャッジ日時 | 2024-06-25 13:36:52 |
合計ジャッジ時間 | 5,203 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
import java.util.*; import java.lang.*; import java.io.*; class Ideone{ public static void main(String[] args) throws Exception{ // your code goes here BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); int max = line.length(); int ans = 1; while(max-->0){ for(int i=0;i<=line.length()-max;i++){ if(check(line.substring(i,i+max))){ System.out.println(max); return; } } } System.out.println(1); } public static boolean check(String line){ int len = line.length(); for(int i=0;i<len;i++){ if(line.charAt(i) != line.charAt(len-i-1)){ return false; } } return true; } }