Cheeseburger Making 2
InterviewTime limit1sMemory limit1024 MB
Given A patties and B cheese slices, decide whether every item can go into burgers that each have exactly one more patty than cheese, and print one valid build if so.
- Level
Easy3 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Seunghyun works at a burger shop that has hamburger patties and slices of cheese to use as ingredients. To make a cheeseburger, pick at least one patty and at least one slice of cheese, then stack the patties and cheese alternately between the bun halves. The number of patties chosen must be exactly one more than the number of cheese slices.
Seunghyun wants to make some cheeseburgers and use up every ingredient in the shop. Find how each cheeseburger should be made so that all patties and cheese slices are used.
Input
The first line contains two integers and , separated by a space. is the number of patties and is the number of cheese slices.
Output
On the first line, print YES if there is a way to use every patty and every cheese slice, otherwise print NO.
If such a way exists, print the number of cheeseburgers on the second line. Then, from the third line on, print lines, each a string that describes how to build one cheeseburger. If the -th ingredient is a patty, the -th character is a. If it is cheese, the -th character is b.
If there are several valid answers, print any one of them.