> 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/ad-hoc/1329-cara-ou-coroa.md).

# 1329 - Cara ou Coroa

## Descrição

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

## Solução

Para resolver esse problema, basta acumular os resultados de Maria e João para cada jogo, lembrando de zerar o placar a cada caso de teste.

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

```c
#include <stdio.h>

int main(){
    int N, R, maria, joao;

    while(scanf("%d", &N)){
        if(!N)  break;

        maria = 0, joao = 0;

        for(int i = 0; i < N; ++i){
            scanf("%d", &R);

            if(R)   ++joao;
            else    ++maria;
        }

        printf("Mary won %d times and John won %d times\n", maria, joao);
    }

    return 0;
}
```

{% endtab %}

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

```cpp
#include <iostream>

using namespace std;

int main(){
    int N, R, maria, joao;

    while(cin >> N){
        if(!N)  break;

        maria = 0, joao = 0;

        for(int i = 0; i < N; ++i){
            cin >> R;

            if(R)   ++joao;
            else    ++maria;
        }

        cout << "Mary won " << maria << " times and John won " << joao << " times" << endl;
    }

    return 0;
}
```

{% endtab %}

{% tab title="JavaScript 12.18" %}

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

while(lines.length){
  let N = parseInt(lines.shift());

  if(!N)  break;

  let maria = lines.shift().trim().split(" ").map((x) => parseInt(x)).reduce((acc, curr) => (!curr ? acc + 1 : acc), 0);
  
  let joao = N - maria;

  console.log(`Mary won ${maria} times and John won ${joao} times`);
}
```

{% endtab %}

{% tab title="Python 3.9" %}

```python
while True:
    try:
        N = int(input())

        R = [int(x) for x in input().strip().split(' ')]
        maria, joao = 0, 0

        for jogo in R:
            if(jogo == 0):
                maria += 1
            else:
                joao += 1
        
        print(f"Mary won {maria} times and John won {joao} times")
    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/ad-hoc/1329-cara-ou-coroa.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.
