Submission #28181

#TimeUsernameProblemLanguageResultExecution timeMemory
28181 (#71)The Ethereum and The Bitcoin (FXCUP2_ethereum)C++11
Compilation error
0 ms0 KiB
#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 (stderr)

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;
             ^