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] ABC010 A

問題 A - ハンドルネーム 回答 S = input() new_name = S + 'pp' print(new_name)

記事を読む

[Python] ABC002 D by python

D - 派閥 from itertools import combinations n, m = map(int, input().split()) matrix_relations = * n for _ in range(n)] # matrixに関係を格納する。...

記事を読む

[Python] ABC017 B

問題 B - choku語 回答 X = input() while X: if len(X)>=2 and X == 'ch': X = X elif X == 'o' or X == 'k' or X == 'u': ...

記事を読む

[Python] ABC012 B

問題 B - 入浴時間 回答 N = int(input()) seconds = N % 60 minutes = (N // 60) % 60 hours = N // (60 ** 2) % 60 s_seconds = '{:02d}'.forma...

記事を読む

[Python] ABC011 D

問題 D - 大ジャンプ 回答 90点回答 深さ優先探索 \(4^8 = 65534 \) 通りであれば全探索ができる。 N, D = map(int, input().split()) X, Y = map(int, input().sp...

記事を読む


Public Domain YottaGin No Rights Reserved.