# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28179 | IE (#71) | 이더리움과 비트코인 (FXCUP2_ethereum) | C++98 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ethereum.h"
#include <algorithm>
using namespace std;
pair<long long, long long> extended_gcd(long long a, long long b) {
if (b == 0) return make_pair(1, 0);
pair<long long, long long> t = extended_gcd(b, a % b);
return make_pair(t.second, t.first - t.second * (a / b));
}
excinfo GetExchangePrice() {
excinfo A = Exchange(100000000);
excinfo B = Exchange(99999999);
long long p = A.BTC - B.BTC;
long long q = A.ETH - B.ETH;
excinfo ret;
if (p >= 0 && q <= 0){
auto v = extended_gcd(p,-q);
ret.BTC = v.first;
ret.ETH = -v.second;
}
else{
auto v = extended_gcd(-p,q);
ret.BTC = -v.first;
ret.ETH = v.second;
}
return ret;
}