XTU 1178A+B

题目描述

小明喜欢做a+b,所以也非常喜欢整数。有一天他看到练习册上的a+b,a和b居然变成了分数形式x/y,非常伤心。他想要是能把分式的分子和分母都加上一个非负整数z,使得分式能化成非负整数就好了。但是他不知道是不是存在这样z,请你帮他计算一下。

输入

第一行是一个整数K,表示样例的个数。以后每行一个样例,为两个整数x,y(1≤x,y≤1e9)。

输出

每行输出一个样例的结果,存在z输出"Yes",否则输出"No"。(引号不要输出)

样例输入

1
1 1

样例输出

Yes

Source

XTU OnlineJudge

设k=(a+z)/(b+z),通过运算可得,当k>=1&&k<=a/b时,则可以。

#include<stdio.h>
int main()
{
int a,b,t;
scanf("%d",&t);
while(t--)
  {
<span style="white-space:pre">	</span>scanf("%d%d",&a,&b);
<span style="white-space:pre">	</span>if(a/b>=1)printf("Yes\n");
<span style="white-space:pre">	</span>else printf("No\n");
<span style="white-space:pre">	</span>
  }
}

XTU 1178A+B,布布扣,bubuko.com

时间: 2024-10-13 04:29:35

XTU 1178A+B的相关文章

xtu summer individual 6 B - Number Busters

Number Busters Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 382B64-bit integer IO format: %I64d      Java class name: (Any) Arthur and Alexander are number busters. Today they've got a competition.

xtu DP Training C.炮兵阵地

炮兵阵地 Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 118564-bit integer IO format: %lld      Java class name: Main 司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队.一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表

xtu summer individual 1 E - Palindromic Numbers

E - Palindromic Numbers Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Description A palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the same when its digits are reversed. In this

xtu summer individual 6 D - Checkposts

Checkposts Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 427C64-bit integer IO format: %I64d      Java class name: (Any) Your city has n junctions. There are m one-way roads between the junctions. A

xtu summer individual 5 D - Subsequence

Subsequence Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 353064-bit integer IO format: %I64d      Java class name: Main There is a sequence of integers. Your task is to find the longest subsequence that sa

xtu summer individual 1 A - An interesting mobile game

An interesting mobile game Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 329564-bit integer IO format: %I64d      Java class name: Main XQ,one of the three Sailormoon girls,is usually playing mobile games o

xtu summer individual 2 C - Hometask

Hometask Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 154A64-bit integer IO format: %I64d      Java class name: (Any) Sergey attends lessons of the N-ish language. Each lesson he receives a hometas

XTU 二分图和网络流 练习题 C. 方格取数(1)

C. 方格取数(1) Time Limit: 5000ms Memory Limit: 32768KB 64-bit integer IO format: %I64d      Java class name: Main 给你一个n*n的格子的棋盘,每个格子里面有一个非负数.从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大. Input 包括多个测试实例,每个测试实例包括一个整数n 和n*n个非负数(n<=20) Output 对

XTU OJ 1175 Hurry Up(三分法&amp;&amp;穷举法)

 Hurry Up Accepted : 88   Submit : 345 Time Limit : 1000 MS   Memory Limit : 65536 KB Problem Description GG is some what afraid of his MM. Once his MM asks, he will always try his best to rush to their home. Obvious, he can run home in straight li