æ•´æ•°ã®é›†åˆA,Bã«ã¤ã„ã¦,次ã®æ¡ä»¶ã‚’満ãŸã™æ•´æ•° xãŒã„ãã¤å˜åœ¨ã™ã‚‹ã‹ç”ãˆã‚ˆã€‚
Ai mod x = 0 ã‹ã¤ x mod Bj = 0 ãŒã™ã¹ã¦ã® i (1 ≤ i ≤ N), j (1 ≤ j ≤ M) ã«ã¤ã„ã¦æˆã‚Šç«‹ã¤ã€‚
(a mod b ã¯aã‚’bã§å‰²ã£ãŸã¨ãã®ä½™ã‚Šã‚’æ„味ã™ã‚‹)
N M A1 A2 ... AN B1 B2 ... BM
入力ã¯ä»¥ä¸‹ã®æ¡ä»¶ã‚’満ãŸã™ã€‚
æ¡ä»¶ã‚’満ãŸã™æ•´æ•° x ãŒã„ãã¤å˜åœ¨ã™ã‚‹ã‹ä¸€è¡Œã§å‡ºåŠ›ã›ã‚ˆã€‚
1 2 18 6 9
1
1 2 256 2 4
7