답안 #28181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28181 2017-07-15T14:18:00 Z (#1210, xdoju) 이더리움과 비트코인 (FXCUP2_ethereum) C++11
컴파일 오류
0 ms 0 KB
#include "ethereum.h"
#include <stdio.h>

excinfo GetExchangePrice() {
  long long V1 = 100000000, V2 = 99999999;
  excinfo A = Exchange(V1);
  excinfo B = Exchange(V2);

  long long BTC = 0, ETH = 0;

  long long X = A.ETH * B.BTC - A.BTC * B.ETH;
  long long Y = B.BTC * V1 - A.BTC * V2;

  long long ETH = Y / X;

  long long BTC = (A.BTC != 0 ? (V1 - A.ETH * ETH) / A.BTC
      : (V2 - B.ETH * ETH) / B.BTC);

  excinfo ret; ret.BTC = BTC; ret.ETH = ETH;
  return ret;
}

Compilation message

ethereum.cpp: In function 'excinfo GetExchangePrice()':
ethereum.cpp:14:13: error: redeclaration of 'long long int ETH'
   long long ETH = Y / X;
             ^
ethereum.cpp:9:22: note: 'long long int ETH' previously declared here
   long long BTC = 0, ETH = 0;
                      ^
ethereum.cpp:16:13: error: redeclaration of 'long long int BTC'
   long long BTC = (A.BTC != 0 ? (V1 - A.ETH * ETH) / A.BTC
             ^
ethereum.cpp:9:13: note: 'long long int BTC' previously declared here
   long long BTC = 0, ETH = 0;
             ^