# AtCoder Regular Contest 035

URL: https://atcoder.jp/contests/arc035/ (opens new window)

# A

s = gets.chomp

(s.length / 2).times do |i|
  if s[i] == "*" || s[s.length - 1 - i] == "*" || s[i] == s[s.length - 1 - i]
    next
  else
    puts "NO"
    exit 0
  end
end

puts "YES"

# B

n = gets.chomp.to_i
t_arr = n.times.map{gets.chomp.to_i}
 
# ペナルティの計算
penalty = 0
time = 0
hash = {}
t_arr.sort_by{|t| t}.each do |t|
  hash[t] ||= 0
  hash[t] += 1
  time += t
  penalty += time
end
 
# 階乗の計算
MAX = 10 ** 9 + 7
factorial = {}
num = 1
(1..10000).each do |i|
  num *= i
  num = num % MAX
  factorial[i] = num
end
Last Updated: 2020/08/15 20:23