#include <iostream> usingnamespace std; bool Judge(int a,int b) { int tt,r; if(a < b){tt = a; a = b; b = tt;} r = a % b; while(r) { a = b; b = r; r = a % b; } if(b !=1)returnfalse; elsereturntrue; } int main() { int a,b,i; int n; while(cin>>n) while(n--&& cin>>a>>b) { a /= b; for(i =2;; i ++) { if(a % i !=0&& Judge(a,i)) {//因b为a和c的最大公倍数,此时a和c应当是无公倍数 cout<<i * b<<endl; break; } } } return0; }
posted on
2009-03-11 20:27Xredman
阅读(221)
评论(0)
编辑收藏举报