{Целевой язык не указан, приведу пример на Haskell}
Цена вычисляется как
C - максимальная цена, которую мы можем себе позволить.
Поэтому , где div - оператор целочисленного деления.
Кодmodule Spinner (spinner, maybeTo) whereimport Control.Monad.Fail as MFail (MonadFail, fail) import System.IO (hFlush, stdout)import Text.Read (readMaybe)import Data.Maybe (maybe)maybeTo :: (MonadFail m) => Maybe b -> String -> m bmaybeTo Nothing msg = MFail.fail msgmaybeTo (Just a) _ = return aspinner :: IO ()spinner = do putStr "Enter an A: " hFlush stdout maybeA <- fmap readMaybe getLine :: IO (Maybe Int) a <- maybeTo maybeA "It's not an Int" putStr "Enter an B: " hFlush stdout maybeB <- fmap readMaybe getLine :: IO (Maybe Int) b <- maybeTo maybeB "It's not an Int" putStr "Enter an C: " hFlush stdout maybeC <- fmap readMaybe getLine :: IO (Maybe Int) c <- maybeTo maybeC "It's not an Int" maybe (putStrLn "You can't use 0 with B var!") (putStrLn . ("The maximum spinner's levers number is " ++) . show) (makeNumber a b c) putStrLn ""makeNumber :: Int -> Int -> Int -> Maybe Int makeNumber _ 0 _ = NothingmakeNumber a b c = Just $ div (c - a) b
a = int(input())
for i in range(a):
b = input()
c = 0
d = True
e = 0
f = False
g = False
h = '\''
for j in b:
if j == '#' and not f:
g = True
break
elif j != ' ':
if d:
print(' ' * c, end='')
elif c > 0:
print(' ', end='')
c = 0
print(j, end='')
if(j == '\"' or j == '\'') and e % 2 == 0:
if f and j == h:
f = False
else:
f = True
h = j
if f:
d = True
else:
d = False
if j == '\\':
e += 1
else:
e = 0
else:
c += 1
r = j == ' '
if g and c > 1:
print(' ', end='')
if i < a - 1:
print()
1
Объяснение: