QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#804658 | #9868. GCD | ucup-team139# | Compile Error | / | / | C++14 | 958b | 2024-12-08 01:51:30 | 2024-12-08 01:51:31 |
Judging History
This is the latest submission verdict.
- [2024-12-08 01:51:31]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-12-08 01:51:30]
- Submitted
answer
#include <bits/stdc++.h>
#define int int64_t
using namespace std;
const int MN = 5004;
int dp[MN][MN];
const int inf = 1e18;
void solve() {
int a,b;
cin>>a>>b;
int gg = gcd(a,b);
for(int i=0; i<MN; ++i) dp[i][0]=1;
dp[0][0]=0;
for(int g=a; g>=gg; --g) {
for(int aog=1; g*aog<=a; ++aog) {
int ca = aog*g;
int cb = b-(b%g);
dp[g][aog]=dp[g][aog-1]+1;
for(int g2=g+g; g2<=ca; g2+=g) if(ca%g2==0) {
/*for(int aog2=0; g2*aog2<=ca; ++aog2) {
int a2 = g2*aog2;
int d = (ca-a2)/g + (cb%g2)/g;
dp[g][aog] = min(dp[g][aog], d+dp[g2][aog2]);
}*/
int aog2 = ca/g2;
int d = (cb%g2)/g;
dp[g][aog] = min(dp[g][aog], d+dp[g2][aog2]);
}
if(gcd(ca,cb)!=g) dp[g][aog]=dp[gcd(ca,cb)][ca/gcd(ca,cb)];//inf;
//cerr<<"dp["<<g<<"]["<<aog<<"]= "<<dp[g][aog]<<'\n';
}
}
cout<<dp[gg][a/gg]<<'\n';
}
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
int t;
cin>>t;
while(t--) solve();
return 0;
}
详细
answer.code: In function ‘void solve()’: answer.code:13:18: error: ‘gcd’ was not declared in this scope 13 | int gg = gcd(a,b); | ^~~