e390:許功蓋問題 & e394:許蓋功問題
e390:許功蓋問題 & e394:許蓋功問題
題目連結:e390:許功蓋問題,e394:許蓋功問題
題意:
e390:許功蓋問題:
每行一個字元,請你判斷它會不會造成許功蓋問題
e394:許蓋功問題:
和前一題類似,只是改為每行一個字串
解法:
這題用C++應該不太好解
所以我選擇用Python
Python用的是Unicode,不會發生許功蓋問題
把所有許功蓋字元列出再搜尋即可
e390:許功蓋問題:
time:23ms
memory used:3.4MB
code:
- from sys import stdin
- ch=["﹏","兝","α","么","功","吒","吭","沔","坼","歿","俞","枯","苒","娉","珮","豹","崤","淚","許","廄","琵","跚","愧","稞","鈾","暝","蓋","墦","穀","閱","璞","餐","縷","擺","黠","孀","髏","躡","尐","佢","汻","岤","狖","垥","柦","胐","娖","涂","罡","偅","惝","牾","莍","傜","揊","焮","茻","鄃","幋","滜","綅","赨","塿","槙","箤","踊","嫹","潿","蔌","醆","嬞","獦","螏","餤","燡","螰","駹","礒","鎪","瀙","酀","瀵","騱","酅","贕","鱋","鱭"]
- while True:
- line=stdin.readline()
- if not line:
- break
- line=line.strip()
- b=0
- for i in range(len(ch)):
- if line==ch[i]:
- b=1
- if b==1:
- print('Yes')
- else:
- print('No')
e394:許蓋功問題:
time:0.1s
memory used:3.5MB
code:
- from sys import stdin
- ch=["﹏","兝","α","么","功","吒","吭","沔","坼","歿","俞","枯","苒","娉","珮","豹","崤","淚","許","廄","琵","跚","愧","稞","鈾","暝","蓋","墦","穀","閱","璞","餐","縷","擺","黠","孀","髏","躡","尐","佢","汻","岤","狖","垥","柦","胐","娖","涂","罡","偅","惝","牾","莍","傜","揊","焮","茻","鄃","幋","滜","綅","赨","塿","槙","箤","踊","嫹","潿","蔌","醆","嬞","獦","螏","餤","燡","螰","駹","礒","鎪","瀙","酀","瀵","騱","酅","贕","鱋","鱭"]
- while True:
- line=stdin.readline()
- if not line:
- break
- line=line.strip()
- b=0
- for i in range(len(ch)):
- for j in range(len(line)):
- if line[j]==ch[i]:
- b=1
- if b==1:
- print('Yes')
- else:
- print('No')
本人的分享到此結束
若有更好的想法或建議,請在留言區留言喔
題外話:
這兩題是程式設計社的學弟出的題目
雖然不算很難,但也十分有水準
升上國三後越來越有「長江後浪推前浪」之感了(我國二的時候也才200多題)
學弟加油!
學弟加油!
Comments
Post a Comment