結果

問題 No.600 かい文回
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-11-24 22:43:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 689 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 73,788 KB
実行使用メモリ 56,148 KB
最終ジャッジ日時 2023-08-30 18:54:50
合計ジャッジ時間 8,419 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,272 KB
testcase_01 AC 127 ms
55,884 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 127 ms
55,592 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 127 ms
55,652 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 123 ms
55,584 KB
testcase_19 AC 124 ms
55,580 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n=scan.nextLong();
        char c='a';
        StringBuilder sb=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);
            //+1
            if((n&1<<i)!=0){
                c=c=='a'?'b':'a';
                sb.append(c);
            }
        }
        String r=new StringBuilder(sb).reverse().toString()+sb;
        if(r.length()==0)r="s";
        System.out.println(r);
    }
}
0