# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27204 | TAMREF | Min-cost GCD (GA9_mcg) | C++11 | 1000 ms | 32768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define va first
#define vb second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
map<pll,int> m;
ll s,t;
int rec(pll p){
if(!p.va||!p.vb) return 0;
if(m[p]) return m[p];
ll x=p.va,y=p.vb;
return m[p]=min(rec(mp(y,x%y))+s,rec(x>=y?mp(x-y,y):mp(x,y-x))+t);
}
int main(){
pll x;
int T;
for(scanf("%d",&T);T--;){
m.clear();
scanf("%lld%lld%lld%lld",&x.va,&x.vb,&s,&t);
printf("%d\n",rec(x));
}
return 0;
}
컴파일 시 표준 에러 (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... |