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. MFC线程(三):线程同步事件(event)与互斥(mutex)

    前面讲了临界区可以用来达到线程同步.而事件(event)与互斥(mutex)也同样可以做到. Win32 API中的线程事件 HANDLE hEvent = NULL; void MainTestFu ...

  2. linux上安装apache以及httpd.conf基本配置

    1.yum安装apache #yum install httpd -y 2.随系统自启动 #chkconfig httpd on 3.开启apache #service httpd start PS: ...

  3. easy ui 实现gridview效果

    前台: // 加载审批步骤列表 function FillStep(flowID) { $('#tbStepList').datagrid({ url: "/System/ApproverS ...

  4. js 日常问题记录

    1.解决ie6下css背景图不缓存 try{ document.execCommand('BackgroundImageCache',false,true); }catch(e){} 2.为ajax设 ...

  5. spring的数据源基本配置

    aplictaionContext-dataSource的配置: <?xml version="1.0" encoding="utf-8"?> &l ...

  6. java设计模式--结构型模式--享元模式

    享元模式 概述 运用共享技术有效地支持大量细粒度的对象. 适用性 当都具备下列情况时,使用Flyweight模式: 1.一个应用程序使用了大量的对象. 2.完全由于使用大量的对象,造成很大的存储开销. ...

  7. android网址

    1. 优麒麟手机助手 https://github.com/ubuntu-kylin/phone_manager 2. http://forum.xda-developers.com/index.ph ...

  8. 2013第49周三IE9文档模式

    今天完善了原有模块的代码和注释,然后继续之前新模块的开发,并写了两边的service接口,除了因为邮件中有部分问题让我分心外,专心下来写代码的感觉真好,今天基本上没遇到多少让我新感悟的技术问题,就总结 ...

  9. 通用多目录makefile的写法

    我的项目文件层次是:项目名称/include.output.src src/admin.stu.tch.common 最外层的Makefile: DEBUG = yMYDEBUG = DEBUGife ...

  10. 利用PartialView返回HTML模型视图