> For the complete documentation index, see [llms.txt](https://xtecna.gitbook.io/solucoes-da-beecrowd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xtecna.gitbook.io/solucoes-da-beecrowd/matematica/1198-o-bravo-guerreiro-hashmat.md).

# 1198 - O Bravo Guerreiro Hashmat

## Descrição

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

## Solução

Basicamente calcular a diferença absoluta de soldados entre os dois exércitos.

{% hint style="info" %}
Este problema envolve números grandes, então tome as precauções necessárias para evitar overflow na sua linguagem de programação escolhida.
{% endhint %}

{% hint style="success" %}
Dito isso, não é necessário usar BigInt em JavaScript!
{% endhint %}

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

```c
#include <stdlib.h>
#include <stdio.h>

int main()
{
    long long int hashmat, oponente;

    while (scanf("%lld %lld", &hashmat, &oponente) != EOF)
    {
        printf("%lld\n", hashmat > oponente ? hashmat - oponente : oponente - hashmat);
    }

    return 0;
}
```

{% endtab %}

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

```cpp
#include <iostream>

using namespace std;

int main()
{
    unsigned long long int a, b;

    while (cin >> a >> b)
    {
        cout << (a > b ? a - b : b - a) << endl;
    }

    return 0;
}
```

{% endtab %}

{% tab title="JavaScript 12.18" %}

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

lines.pop();

let p = 0;
while (p < lines.length) {
    let [hashmat, oponente] = lines[p++].trim().split(' ').map((x) => parseInt(x));

    console.log(`${hashmat > oponente ? hashmat - oponente : oponente - hashmat}`);
}
```

{% endtab %}

{% tab title="Python 3.9" %}

```python
while True:
    try:
        hashmat, oponente = [int(x) for x in input().strip().split(' ')]

        print(f'{hashmat - oponente if hashmat > oponente else oponente - hashmat}')
    except EOFError:
        break
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/matematica/1198-o-bravo-guerreiro-hashmat.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.
