Algorithm
Problem Name: beecrowd | 3346
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/3346
GDP Fluctuation
By Leandro Zatesko, Federal University of Technology of Paraná Brazil
Timelimit: 1
The South is one of the regions which contribute the most to the Gross Domestic Product (GDP) in Brazil. However, due to the pandemic of COVID-19, the economy in the three states of the South has been much affected. Alice, a researcher of the University of the South, collected data on the GDP fluctuation in the whole South in each of the two last years. Each GDP fluctuation is represented by a percentage, in a manner that a positive percentage indicates growth in the corresponding period of one year, whilst a negative percentage indicates decrease.
Bob, a politician, is going to give an interview to the press tomorrow. Based on the two values collected by Alice, Bob wants to calculate the GDP fluctuation corresponding to the whole analysed period of two years, so he doesn't talk nonsense in the interview.
Input
The input consists of two values F1 and F2 (-100.00 ≤ F1, F2 ≤ 100.00), which correspond to the GDP fluctuations in the first and in the second years analysed by Alice, respectively. The values are given with exactly two digits after the decimal point.
Output
Print a value, with exactly six digits after the decimal point, that corresponds to the GDP fluctuation in the whole analysed period of two years.
Input Samples | Output Samples |
-4.00 5.00 |
0.800000 |
66.66 88.88 |
214.787408 |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main() {
double a,b;
scanf("%lf%lf", &a,&b);
printf("%.6lf\n", ((((1.0 + a/100.00) * (1.0 + b/100.00)) - 1.0) * 100.0));
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int main() {
double a,b;
cin >> a >> b;
printf("%.6lf\n", ((((1.0 + a/100.00) * (1.0 + b/100.00)) - 1.0) * 100.0));
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Javascript Programming
Code -
Javascript Programming
const { readFileSync } = require("fs")
const [flutuationA, flutuationB] = readFileSync("/dev/stdin", "utf8")
.split(" ", 2)
.map(Number.parseFloat)
.map(flutt => flutt * 1e-2)
const FLUTUATION_PRECISION = 6
const totalFlutuation = (1 + flutuationA) * (1 + flutuationB) - 1.00
const totalFlutuationInPercent = totalFlutuation * 100.00
console.log(totalFlutuationInPercent.toFixed(FLUTUATION_PRECISION))
Copy The Code &
Try With Live Editor
Input
Output
#4 Code Example with Javascript Programming
Code -
Javascript Programming
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const pegarValores = (line) => line.split(" ").map(a => Number(a));
let [a, b] = pegarValores(lines.shift())
let flutuacao = ((((1.0 + a/100.00) * (1.0 + b/100.00)) - 1.0) * 100.0)
console.log(flutuacao.toFixed(6));
Copy The Code &
Try With Live Editor
Input
Output
#5 Code Example with Python Programming
Code -
Python Programming
f1,f2=map(float,input().split())
print(f'{(100.00+f1)*(f2/100.00+1)-100.00:.6f}')
Copy The Code &
Try With Live Editor
Input
Output