首页 > 其他 > 详细

noip赛前模拟

时间:2017-10-24 13:53:19      阅读:255      评论:0      收藏:0      [点我收藏+]

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

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赛前模拟

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!