P - P

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

有三个正整数a,b,c(0<a,b,c<10^6),其中c不等于b。若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c。 
 

Input

第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b。 
 

Output

输出对应的c,每组测试数据占一行。 
 

Sample Input

2 6 2 12 4
 

Sample Output

4 8
 

 #include<cstdio>
#include<cstring>
bool cmp(int a,int b)
{
int c;
while(b!=)//辗转相除法
{
c=a%b;
a=b;
b=c;
}
if(a==)
return ;
else
return ;
}
int main()
{
int a,b,c;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%d%d",&a,&b); int m=a/b;
for(int i=;;i++)
{
if(cmp(i,m))
{
printf("%d\n",i*b);
break;
}
}
}
}

CDZSC_2015寒假新人(2)——数学 P的更多相关文章

  1. CDZSC_2015寒假新人(2)——数学 H

    H - H Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  2. CDZSC_2015寒假新人(2)——数学 G

    G - G Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  3. CDZSC_2015寒假新人(2)——数学 D

    D - D Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  4. CDZSC_2015寒假新人(2)——数学 C

    C - C Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  5. CDZSC_2015寒假新人(2)——数学 B

    B - B Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  6. CDZSC_2015寒假新人(2)——数学 A

    A - A Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  7. CDZSC_2015寒假新人(1)——基础 i

    Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you mus ...

  8. CDZSC_2015寒假新人(1)——基础 h

    Description Ignatius was born in a leap year, so he want to know when he could hold his birthday par ...

  9. CDZSC_2015寒假新人(1)——基础 g

    Description Ignatius likes to write words in reverse way. Given a single line of text which is writt ...

随机推荐

  1. uva11292贪心基础题目

    C - 贪心 基础 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bi ...

  2. C#将十六进制的文本转换到整型数据

    1 length1 = Int32.Parse(szLine.Substring(1, 2), System.Globalization.NumberStyles.HexNumber);//计算这一行 ...

  3. C#串口扫描

    1.传入serialport 和待显示串口的Commbox private void Search_AddSerialToComboBox(SerialPort MyPort, ComboBox My ...

  4. forward 和redirect的区别

    1.从地址栏显示来说 forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL的响应内容读取过来,然后把这些内容再发给浏览器.浏览器根本不知道服务器发送的内容从哪里来的,所以它的地 ...

  5. Ubuntu 修改 Apache2 用户组 方法

    检查/etc/apache2/envvars文件,发现其中需要使用/etc/apache2/envvars文件中的以下几个环境变量 export APACHE_RUN_USER=www-data ex ...

  6. NAS4Free 安装配置(一)开箱图

    拆箱记录 东西不错,做工很好 包装箱 背面 正面(未装前面板) 底部 前面板打开后 打开上盖 开机正面图

  7. iOS -多字体混合

    label 加下划线 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 300, 100)];    label.b ...

  8. [TYVJ] P1002 谁拿了最多奖学金

    谁拿了最多奖学金 背景 Background NOIP2005复赛提高组第一题   描述 Description 某校的惯例是在每学期的期末考试之后发放奖学金.发放的奖学金共有五种,获取的条件各自不同 ...

  9. apache服务器参数设置

    全局参数设置 ServerRoot:服务器根目录 apache安装目录[我的为:/usr/local/apache/] 用于指定apache服务器的配置文件及日志文件存放的根目录.服务器的基础目录,a ...

  10. TXMLDocument换行的两种方案

    手写代码:   XML格式化使用msxml引擎,Delphi代码如下: Delphi/Pascal code   ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...