YottaGin

Freedom is a responsible choice.

[Python] ABC007 B

2019/11/3 2019/11/3 アルゴリズム, プログラミング

問題

B – 辞書式順序

入力例/出力例と同じ値になるようにしてみる。

組み込み関数の chr(i) と ord(c) を使う。

回答

A = input()
lst_a = list(A)

if len(lst_a) >=2:
    print(''.join(lst_a[:-1]))
elif lst_a[0] == 'a':
    print('-1')
else:
    print(chr(ord(lst_a[0])-1))

Atcoder, Python GinO

関連記事

[Python] ブラックジャックを作る

以下を参考にして…。 Pythonでブラックジャック作ったよ Pythonでブラックジャック作ってみた pythonでブラックジャックを作る ルール 初期カードは52枚。引く際にカードの重複は無いようにするプレイヤーとディーラーの2人対戦プレーヤー...

記事を読む

[Python] ABC001 A

A - 積雪深差 h1 = int(input()) h2 = int(input()) print(h1-h2) さすがに解ける。 int(input()) input()はstirngを返すのでint()でintに変換する。

記事を読む

[Python] コマンドプロンプトでtermcolorが文字化けする時

windows10のコマンドプロンプトでpythonのtermcolorで出力に色をつけようとすると、色ではなく文字化けが発生します。 termcolor は unix で使われる ANSIエスケープシーケンスというものを使うためで、これが windows のコマンドプ...

記事を読む

[Python] ABC001 C

C - 風力観測 deg, dis =(int(x) for x in input().split()) direction = '' w = -1 lst_wind_direction =['NNE','NE','ENE', 'E','ESE','SE','SSE',...

記事を読む

[Python] ABC018 C 100点 いもす法

問題 C – 菱型カウント 回答 スライドの解説に従うとTLEになってしまいました。 以下を参考にして、いもす法を用いました。 ABC018 C - 菱型カウント # 参照 R, C, K = map(int, input()...

記事を読む


Public Domain YottaGin No Rights Reserved.