#include <iostream>
#include <cstdint>
using namespace std;
// TODO: Implement constexpr int32_t computeScale(int32_t maxAdc, int32_t maxVoltage_mV)
constexpr int32_t computeScale(int32_t maxAdc, int32_t maxVoltage_mV)
{
// I want to computer microvolts per ADC count at compile time
/*
maxVoltage = 3300 mV
maxADC = 4095
y = mx + b
y(x) = (3300 - 0)/(4095 - 0) * (x - 0) + ymin
y(x) = (3300/4095) * x + 0
y(x) = (3300/4095) * x
y(x) = ((3300/4095) * (1000)) * x
*/
int32_t maxVoltage_uV = maxVoltage_mV*1000;
return maxVoltage_uV / maxAdc;
}
// TODO: Define constexpr int32_t SCALE_UV = ...
constexpr int32_t SCALE_UV = computeScale(4095, 3300);
int main() {
int32_t x;
if (!(cin >> x)) return 0;
// TODO: Compute voltage_uv using SCALE_UV
int32_t voltage_uV = x*SCALE_UV;
// TODO: Print the result
cout << voltage_uV;
return 0;
}
Input
0
Expected Output
0