This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str = gets | |
str.chomp! | |
str.reverse! | |
a = 0 | |
while a < str.size | |
result = true #これがループ終了時に真ならNo | |
s = 0 #次にワープする文字数 | |
if a+5 <= str.size #配列外参照を危惧 | |
if str[a,5] == "maerd"||str[a,5] == "esare" #5文字とった時にどちらかに当てはまればセーフ | |
result = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = gets.to_i | |
AR = Array.new | |
a.times{AR << gets.to_i} #a行に渡る配列を取得 | |
AR.uniq! #重複要素を削除 | |
puts AR.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N,A,B = gets.split.map(&:to_i) #N,A,Bを取得 | |
ans = 0 | |
def calu(n) #各桁の和を計算する関数を宣言 | |
a = n #rubyの関数の仕様を把握してないので一応 | |
@i = 0 #各桁の和を代入する変数 | |
while a >= 10 #各桁の和を求める | |
@i += a%10 | |
a /= 10 | |
end | |
@i += a%10 #1桁の数を拾うために |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = gets.to_i #配列のサイズを取得(特にこのあと使わないけど) | |
ar = gets.split.map(&:to_i) #空白区切りの配列を取得 | |
ans = 1000000000 #答えの変数を大きい値で初期化 | |
for moke in ar do #配列の中の要素をmokeに入れてぶん回す | |
s = 0 #mokeが2で割れる回数を0で初期化 | |
while moke%2==0 do #このループ内でmokeが2で割れる回数を求める | |
moke /= 2 | |
s += 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
moke = gets #文字列を取得 | |
puts moke.count("1") #.countの引数に"1"を指定することで、1の数を出力 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a,b=gets.split.map(&:to_i) #空白区切りの整数を取得 | |
puts((a*b)%2==0 ? "Even" : "Odd") #かけた値の偶奇を判定 |
NewerOlder