# 1021 - Notas e Moedas

## Descrição

{% embed url="<https://www.urionlinejudge.com.br/judge/pt/problems/view/1021>" %}

## Solução

Para entender o raciocínio para resolver este problema, consulte [1018 - Cédulas](/solucoes-da-beecrowd/iniciante/1018-cedulas.md).

Entretanto, temos alguns detalhes aqui: é um pouco problemático obter o resto da divisão para números não inteiros. Por isso, eu decidi que seria uma boa multiplicar por 100 todos os valores envolvidos para me certificar de que só faria manipulação com números inteiros. Também simplifiquei o código para evitar repetições, fazendo com que na hora de imprimir os valores, também seja necessário dividir por 100.

{% tabs %}
{% tab title="C99" %}

```c
#include <stdio.h>

int main(){
    int notas[] = {10000, 5000, 2000, 1000, 500, 200};
    int moedas[] = {100, 50, 25, 10, 5, 1};
    int reais, centavos;

    scanf("%d.%d", &reais, &centavos);
    reais = 100 * reais + centavos;

    printf("NOTAS:\n");
    for(int i = 0; i < 6; ++i){
        printf("%d nota(s) de R$ %.2lf\n", reais/notas[i], notas[i]/100.0);
        reais %= notas[i];
    }

    printf("MOEDAS:\n");
    for(int i = 0; i < 6; ++i){
        printf("%d moeda(s) de R$ %.2lf\n", reais/moedas[i], moedas[i]/100.0);
        reais %= moedas[i];
    }

    return 0;
}
```

{% endtab %}

{% tab title="C++17" %}

```cpp
#include <cstdio>

int main(){
    int notas[] = {10000, 5000, 2000, 1000, 500, 200};
    int moedas[] = {100, 50, 25, 10, 5, 1};
    int reais, centavos;

    scanf("%d.%d", &reais, &centavos);
    reais = 100 * reais + centavos;

    printf("NOTAS:\n");
    for(int i = 0; i < 6; ++i){
        printf("%d nota(s) de R$ %.2lf\n", reais/notas[i], notas[i]/100.0);
        reais %= notas[i];
    }

    printf("MOEDAS:\n");
    for(int i = 0; i < 6; ++i){
        printf("%d moeda(s) de R$ %.2lf\n", reais/moedas[i], moedas[i]/100.0);
        reais %= moedas[i];
    }

    return 0;
}
```

{% endtab %}

{% tab title="JavaScript 12.18" %}

```javascript
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var lines = input.split("\n");

let [reais, centavos] = lines.shift().trim().split('.').map((x) => parseInt(x));
let valor = 100 * reais + centavos;

notas = [10000, 5000, 2000, 1000, 500, 200];
moedas = [100, 50, 25, 10, 5, 1];

console.log("NOTAS:");
notas.forEach((nota) => {
  console.log(`${Math.floor(valor/nota).toFixed(0)} nota(s) de R$ ${(nota/100).toFixed(2)}`);
  valor %= nota;
});

console.log("MOEDAS:");
moedas.forEach((moeda) => {
  console.log(`${Math.floor(valor/moeda).toFixed(0)} moeda(s) de R$ ${(moeda/100).toFixed(2)}`);
  valor %= moeda;
});

```

{% endtab %}

{% tab title="Python 3.9" %}

```python
reais, centavos = [int(x) for x in input().strip().split('.')]
reais = reais * 100 + centavos

notas = [10000, 5000, 2000, 1000, 500, 200]
moedas = [100, 50, 25, 10, 5, 1]

print("NOTAS:")
for nota in notas:
    print(f"{reais//nota} nota(s) de R$ {(nota/100):.2f}")
    reais %= nota

print("MOEDAS:")
for moeda in moedas:
    print(f"{reais//moeda} moeda(s) de R$ {(moeda/100):.2f}")
    reais %= moeda
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xtecna.gitbook.io/solucoes-da-beecrowd/iniciante/1021-notas-e-moedas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
