> 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/iniciante/1019-conversao-de-tempo.md).

# 1019 - Conversão de Tempo

## Descrição

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

## Solução

Para calcular o número de horas cheias que existem em um tempo em segundos, basta pegar a divisão inteira deste tempo por 3600, a quantidade de segundos em uma hora. Após pegar o número de horas cheias, a única informação que permanece relevante é o resto da divisão por 3600, já que o resto você já converteu em horas. Seguindo um raciocínio similar para os minutos, podemos calcular rapidamente os valores que precisamos. Vamos testar nossa ideia com 140153 segundos.

1. Tem 38 horas completas em 140153 segundos, que calculamos dividindo 140153/3600.
2. Fora dessas 38 horas completas, temos 3353 segundos que podemos continuar convertendo (resto da divisão de 140153 por 3600).
3. Tem 55 minutos nestes 3353, pois 3353/60 = 55.
4. Fora desses 55 minutos completos, sobraram 53 segundos.
5. Logo, nossa resposta é 38 horas, 55 minutos e 53 segundos.

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

```c
#include <stdio.h>

int main(){
    int segundos, horas, minutos;

    scanf("%d", &segundos);

    horas = segundos/3600;
    segundos %= 3600;
    minutos = segundos/60;
    segundos %= 60;

    printf("%d:%d:%d\n", horas, minutos, segundos);

    return 0;
}
```

{% endtab %}

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

```cpp
#include <iostream>

using namespace std;

int main(){
    int segundos, horas, minutos;

    cin >> segundos;

    horas = segundos/3600;
    segundos %= 3600;
    minutos = segundos/60;
    segundos %= 60;

    cout << horas << ':' << minutos << ':' << segundos << endl;

    return 0;
}
```

{% endtab %}

{% tab title="JavaScript 12.18" %}

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

let segundos = parseInt(lines.shift());

let horas = Math.floor(segundos / 3600);
segundos %= 3600;
let minutos = Math.floor(segundos / 60);
segundos %= 60;

console.log(`${horas}:${minutos}:${segundos}`);
```

{% endtab %}

{% tab title="Python 3.9" %}

```python
segundos = int(input())

horas = segundos//3600
segundos %= 3600
minutos = segundos//60
segundos %= 60

print(f"{horas}:{minutos}:{segundos}")
```

{% 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/iniciante/1019-conversao-de-tempo.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.
