自爆魂

博客园 首页 新随笔 联系 订阅 管理

http://acm.hdu.edu.cn/showproblem.php?pid=4993

满足ax + by = c的x,y对数

水题,暴力

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define clr0(x) memset(x,0,sizeof(x))
typedef long long LL;
int a,b,c;

int main() {
	int _;RD(_);while(_--){
	    RD3(a,b,c);
	    if(a > b)
            swap(a,b);
        int ans = 0;
	    for(int i = 1;;++i){
            int x = c - a * i;
            if(x <= 0)
                break;
            if(x%b == 0)
                ans++;
	    }
        printf("%d\n", ans);
	}
	return 0;
}


posted on 2014-10-17 14:16  自爆魂  阅读(124)  评论(0编辑  收藏  举报