7-3 杯具倒水 (25分)

 

(机器人协会友情赞助)

在你面前有两个不规则的杯具,分别容积为a升和b升,还有一个水缸(水无限多)可供装水,那么能不能通过两个杯具的装倒水操作,量出c升的水?

输入格式:

输入的第一行包含一个整数n(n<100),表示包括表示测试数据数 接下来n行,每行三个整数a,b,c其中(1<=a

输出格式:

输出n行 每行输出一个整数,1表示可量出c升水,0表示不能

输入样例:

在这里给出一组输入。例如:

3
3 5 4
7 11 5
9 15 10

输出样例:

在这里给出相应的输出。例如:

1
1
0
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map>
#include<set>
using namespace std;
const int inf=0x3fffffff;
const int maxn=10010;

int gcd(int a,int b){
	
	if(b==0) return a;
	
	return gcd(b,a%b);
}

int main(){

	int n;
	int a,b,c;
	
	cin>>n;
	for(int i=0;i<n;i++){
		
		cin>>a>>b>>c;
		int d = gcd(a,b);
		
		if(c%d == 0) cout<<"1"<<endl;
		else cout<<"0"<<endl;
	}


	return 0;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值