#Lutece1556. Excited Pe0ple
Excited Pe0ple
Migrated from Lutece 1556 Excited Pe0ple
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There is a red team with people where people has a number , and a blue team with people where people has a number .
If there is a red team member with and a blue team member with that and are not relatively prime, they will be unexcited.
In order to make everyone excited, they remove some people from two teams.
But the removed people are also unexcited, so they want to remove minimum numbers of people.
What is the minimum numbers of people must to be removed so that the remained people are all excited.
Input
The first line contains two numbers and , indicating the number of red team members and blue team members.
The second line contains numbers .
The third line contains numbers .
Output
The minimum numbers of people must to be removed so that the remained people are all excited.
Samples
Resources
The 15th UESTC Programming Contest Preliminary