hdu 4993

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
", ans);
	}
	return 0;
}


原文地址:https://www.cnblogs.com/zibaohun/p/4046785.html