码迷,mamicode.com
首页 > 其他好文 > 详细

noip赛前模拟

时间:2017-10-24 14:07:20      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:string   typedef   技术   etc   stdio.h   col   type   play   isp   

比赛就是艺术,艺术就是爆炸。

T1

输出m-gcd(n,m)

技术分享
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;
LL n,m,t;
template <class T> void read(T&x)
{
  x=0;char c=getchar();int f=0;
  while(c<0||c>9){f|=(c==-);c=getchar();}
  while(c>=0&&c<=9)x=(x<<3)+(x<<1)+(c^=48),c=getchar();
  x=f?-x:x;
}
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
int main()
{
  freopen("hdogs.in","r",stdin);
  freopen("hdogs.out","w",stdout);
  read(t);
  while(t--)
  {
      read(n);read(m);
      printf("%d\n",max(m-gcd(n,m),0));
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
View Code

 

noip赛前模拟

标签:string   typedef   技术   etc   stdio.h   col   type   play   isp   

原文地址:http://www.cnblogs.com/new-hand/p/7723029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!