# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27208 | TAMREF | Min-cost GCD (GA9_mcg) | C++11 | 286 ms | 2024 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int mx=300;
ll x,y,p,q;
ll eu[mx], dp[2*mx];
int E;
void workgcd(ll u, ll v){
eu[E++]=v;
if(!v) return;
workgcd(v,u%v);
}
int main(){
int T;
for(scanf("%d",&T);T--;){
scanf("%lld%lld%lld%lld",&x,&y,&p,&q);
E=0;
fill(dp,dp+2*mx,0);
eu[E++]=max(x,y);
workgcd(max(x,y),min(x,y));
for(int i=E-3;i>=0;i--){
dp[2*i]=min(dp[2*i+2]+p,dp[2*i+3]+q*(eu[i]/eu[i+1]));
dp[2*i+1]=min(dp[2*i+2]+q*(eu[i]/eu[i+1]),dp[2*i]+p);
}
printf("%lld\n",x>=y?dp[0]:dp[1]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |