#883. 韩信点兵_1

韩信点兵_1

说明

<style type="text/css">#toc, .toc, .mw-warning { border: 1px solid rgb(170, 170, 170); background-color: rgb(249, 249, 249); padding: 5px; font-size: 95%; }#toc h2, .toc h2 { display: inline; border: medium none; padding: 0pt; font-size: 100%; font-weight: bold; }#toc #toctitle, .toc #toctitle, #toc .toctitle, .toc .toctitle { text-align: center; }#toc ul, .toc ul { list-style-type: none; list-style-image: none; margin-left: 0pt; padding-left: 0pt; text-align: left; }#toc ul ul, .toc ul ul { margin: 0pt 0pt 0pt 2em; }#toc .toctoggle, .toc .toctoggle { font-size: 94%; }body { font-family: '宋体'; font-size: 10pt; text-align: justify; }table { }td { border-collapse: collapse; text-align: left; vertical-align: top; }p, h1, h2, h3, li { font-family: '宋体'; font-size: 10pt; text-align: justify; }</style>

淮安民间传说着一则故事——“韩信点兵”,其次有成语“韩信点兵,多多益善”。韩信带1500名兵士打仗,战死四五百人,站3人一排,多出2人;站5人一排,多出4人;站7人一排,多出6人。韩信马上说出人数:1049。如果我给你一些条件,你能给我满足条件的最小正整数么?

当然,这道题是简单的。给你的每组数据有三行数字,每行数字的第一个数是除数 d ,第二个数是余数 m,然后请你求出一个最小的正整数 n(n < 1000,000),此n能使这三行数字同时满足 n/d == x……m.

输入格式

<style type="text/css">#toc, .toc, .mw-warning { border: 1px solid rgb(170, 170, 170); background-color: rgb(249, 249, 249); padding: 5px; font-size: 95%; }#toc h2, .toc h2 { display: inline; border: medium none; padding: 0pt; font-size: 100%; font-weight: bold; }#toc #toctitle, .toc #toctitle, #toc .toctitle, .toc .toctitle { text-align: center; }#toc ul, .toc ul { list-style-type: none; list-style-image: none; margin-left: 0pt; padding-left: 0pt; text-align: left; }#toc ul ul, .toc ul ul { margin: 0pt 0pt 0pt 2em; }#toc .toctoggle, .toc .toctoggle { font-size: 94%; }body { font-family: '宋体'; font-size: 10pt; text-align: justify; }table { }td { border-collapse: collapse; text-align: left; vertical-align: top; }</style>

第一行是数据的组数 nCase (n<=5),以下有3nCase行。每三行是一组数据,就是给你的三对数据。

输出格式

<style type="text/css">#toc, .toc, .mw-warning { border: 1px solid rgb(170, 170, 170); background-color: rgb(249, 249, 249); padding: 5px; font-size: 95%; }#toc h2, .toc h2 { display: inline; border: medium none; padding: 0pt; font-size: 100%; font-weight: bold; }#toc #toctitle, .toc #toctitle, #toc .toctitle, .toc .toctitle { text-align: center; }#toc ul, .toc ul { list-style-type: none; list-style-image: none; margin-left: 0pt; padding-left: 0pt; text-align: left; }#toc ul ul, .toc ul ul { margin: 0pt 0pt 0pt 2em; }#toc .toctoggle, .toc .toctoggle { font-size: 94%; }body { font-family: '宋体'; font-size: 10pt; text-align: justify; }table { }td { border-collapse: collapse; text-align: left; vertical-align: top; }</style>

对于每组输入,输出一行,是所求得的最小正整数。

样例

2
3 2
5 4
7 6
9 2
7 3
6 5
104
101