結果

問題 No.600 かい文回
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-11-24 22:51:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,158 bytes
コンパイル時間 4,750 ms
コンパイル使用メモリ 76,304 KB
実行使用メモリ 56,136 KB
最終ジャッジ日時 2023-08-18 05:01:12
合計ジャッジ時間 6,575 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,624 KB
testcase_01 AC 127 ms
55,736 KB
testcase_02 AC 126 ms
55,580 KB
testcase_03 AC 126 ms
55,780 KB
testcase_04 AC 126 ms
56,008 KB
testcase_05 AC 124 ms
55,460 KB
testcase_06 AC 125 ms
55,208 KB
testcase_07 AC 125 ms
55,528 KB
testcase_08 AC 124 ms
55,532 KB
testcase_09 AC 130 ms
55,576 KB
testcase_10 AC 125 ms
55,360 KB
testcase_11 AC 126 ms
55,736 KB
testcase_12 AC 126 ms
55,516 KB
testcase_13 AC 125 ms
55,524 KB
testcase_14 AC 126 ms
55,984 KB
testcase_15 AC 128 ms
55,452 KB
testcase_16 AC 124 ms
55,692 KB
testcase_17 AC 124 ms
55,496 KB
testcase_18 AC 125 ms
55,652 KB
testcase_19 AC 123 ms
56,136 KB
testcase_20 AC 125 ms
55,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n=scan.nextLong();
        String[] d=new String[32];
        int p=1;
        for(int i=0;i<16;++i){
            d[i]=Character.toString((char)(97+i));
        }
        for(int i=16;i<32;++i){
            int x=(i-16)/4;
            int y=(i-16)%4;
            char[] k={(char)(97+16+x),(char)(97+20+y)};
            d[i]=new String(k);
        }
        String c="a";
        StringBuilder sb=new StringBuilder();
        StringBuilder rev=new StringBuilder();
        int h=-1;
        for(int i=30;i>=0;--i){
            if(1L<<i>n){continue;}
            h=i;break;
        }
        for(int i=h-1;i>=0;--i){
            //2bai
            sb.append(c);
            rev.append(new StringBuilder(c).reverse());
            //+1
            if((n&1<<i)!=0){
                c=d[p++];
                sb.append(c);
                rev.append(new StringBuilder(c).reverse());
            }
        }
        String r=rev.reverse().toString()+sb;
        if(r.length()==0)r="s";
        System.out.println(r);
    }
}
0