這篇文章收錄所有我能一行解且不用分號 的題目

基礎題庫

a001. 哈囉

AC(19ms,3.3MB)
1
print('hello,',input())

a002. 簡易加法

AC(21ms,3.3MB)
1
print(sum(map(int,input().split())))

b757. 頸美椰子樹

AC(18ms,3.4MB)
1
print('%g'%(float(input())*9/5+32))

c185. Hey Jude

AC(18ms,3.3MB)
1
print('Hey',input())

c221. A+B problem (駭客題)
這題蠻特別的,我們只需要輸出兩個都在int範圍內但是加起來會超過int範圍 的整數就AC了。

AC(2ms,340KB)
1
print('2147483646 2')

c316. 最遠點對!前傳
這題如果有看討論區,都知道可以投機取巧,直接輸入313、472這兩個數拿到這題的AC。
不過我也有認真解這一題:我的解法

AC(26ms,3.3MB)
1
print('313 472')

c379. 成為出題者

AC(18ms,3.3MB)
1
print(int(int(input())*0.3))

c572. Hello CIA!
這道超級水題也出現3年了,結果只有189人過???

AC(18ms,3.3MB)
1
print('Hello CIA!')

c716. Johnny B. Goode

AC(17ms,3.3MB)
1
print('Go, '+input()+', go go')

d049. 中華民國萬歲!

AC(32ms,3.3MB)
1
print(int(input())-1911)

d050. 妳那裡現在幾點了?

AC(20ms,3.3MB)
1
print((int(input())+9)%24)

d051. 糟糕,我發燒了!

AC(20ms,3.3MB)
1
print('%.3f'%((int(input())-32)/9*5))

d058. BASIC 的 SGN 函數

AC(35ms,3.3MB)
1
print(eval("int({0}>0) - int({0}<0)".format(int(input()))))

d060. 還要等多久啊?

AC(19ms,3.3MB)
1
print( ( 85 - int(input()) ) % 60)

d063. 0 與 1
這題真的是超級水題

AC(18ms,3.3MB)
1
print(1-int(input()))

d064. ㄑㄧˊ 數?
原來Python也有和C、C++一樣可以在print裡面塞if-else判斷式的用法。

AC(18ms,3.3MB)
1
print('Odd' if int(input())%2 else 'Even')

d065. 三人行必有我師

AC(18ms,3.3MB)
1
print(max(list(map(int,input().split()))))

d068. 該減肥了!
利用format、eval,還有判斷式,把這題壓在一行內解決,太無情了。

AC(34ms,3.3MB)
1
print(eval("{0} - int({0}>50)".format(int(input()))))

d073. 分組報告
這是題目說的

1, 2, 3 為第一組,4, 5, 6 為第二組

這是拿整數3整除的結果

0, 1, 2, 為0,3, 4, 5, 為1

所以我們先將上面的結果-1,然後整除3,就能和下面的結果一樣,然後因為組別從1開始數,所以要+1。
對了,這篇好欸一行解不是我貼出來的,我只是根據這個公式給出我的看法而已。

AC(18ms,3.3MB)
1
print(((int(input())-1)//3)+1)

d299. 程式設計師的面試問題
投機取巧😂

AC(25ms,3.2MB)
1
print('29786 + 850 + 850 = 31486')

d460. 山六九之旅

AC(19ms,3.3MB)
1
print(eval('({0}>5)*590+({0}>11)*200+({0}>17)*100+({0}>59)*(-491)'.format(int(input()))))

d461. 班際籃球賽

AC

這題簡單到不能再簡單了,只要把輸入的數字-1然後輸出就好。

1
print(int(input())-1)

d498. 我不說髒話

AC(21ms,3.3MB)
1
for i in range(int(input())):print('I don\'t say swear words!')

g216. 2^(10^n)
這題我一開始以為是用快速冪做,但後來看清楚輸出說明後,頓時恍然大悟,原來只是要輸出題目 啊。

AC(17ms,3.3MB)
1
print('2^(10^%d)'%int(input()))

原創/不分類題庫

f669. FJCU_109_Winter_Day1_Lab4 字串反轉
這題怎麼只有154人通過啊,明明很簡單。

AC(33ms,3.3MB)
1
print(input()[::-1])

封面圖源:Pixiv