Submission #27204

#TimeUsernameProblemLanguageResultExecution timeMemory
27204TAMREFMin-cost GCD (GA9_mcg)C++11
14 / 100
1000 ms32768 KiB
#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; }

Compilation message (stderr)

mcg.cpp: In function 'int main()':
mcg.cpp:19:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d",&T);T--;){
                       ^
mcg.cpp:21:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld%lld",&x.va,&x.vb,&s,&t);
                                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...