HDU 4993Revenge of ex-Euclid(暴力)

来源:互联网 发布:合肥气象数据 编辑:程序博客网 时间:2024/06/01 07:34

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


给出a,b,c要求算出满足ax+by=c的(x,y)有几组   直接暴力

#include<iostream>#include<cstdio>#include<set>#include<string>#include<string.h>#include<cstring>#include<vector>#include<map>#include<queue>#include<stack>#include<cctype>#include<algorithm>#include<sstream>#include<utility>#include<cmath>#define mt(a) memset(a,0,sizeof (a))#define fl(a,b,c) fill(a,b,c)#define SWAP(a,b,t) (t=a,a=b,b=t)#define inf 1000000using namespace std;typedef long long ll;int dp[500][300];#define offset 100int main(){int T;cin >> T;while (T--){int x, y, z;scanf("%d %d %d", &x, &y, &z);int ans = 0;for (int i = 1; i <= 1000000; i++){if (i*x >= z)break;if ((z - i*x) % y == 0)ans++;}printf("%d\n", ans);}return 0;}


0 0