Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int rodadas, a, b;
- int vitoriasapo = 0, vitoriashuas = 0;
- scanf("%d", &rodadas);
- for (int i = 0; i < rodadas; i++) {
- scanf("%d %d", &a, &b);
- int ehPrimoA = 1, ehPrimoB = 1;
- for (int j = 2; j <= a / 2; j++) {
- if (a % j == 0) {
- ehPrimoA = 0; //n?o ? primo
- break;
- }
- }
- if(a == 1){
- ehPrimoA = 0; //caso especial do 1
- }
- for (int j = 2; j <= b / 2; j++) {
- if (b % j == 0) {
- ehPrimoB = 0; //n?o ? primo
- break;
- }
- }
- if(b == 1){
- ehPrimoB = 0; //caso especial do 1
- }
- // pedra vs tesoura
- if ((a % 2 == 0 && a != 2) && (b%2 != 0 && (ehPrimoB == 0))) {
- vitoriasapo++;
- }
- else if ((a % 2 != 0 && (ehPrimoA == 0)) && ( b % 2 == 0 && b != 2)) {
- vitoriashuas++;
- }
- // papel vs pedra
- else if (( b % 2 == 0 && b != 2) && ehPrimoA) {
- vitoriasapo++;
- }
- else if ((a % 2 == 0 && a != 2) && ehPrimoB) {
- vitoriashuas++;
- }
- //tesoura vs papel
- else if ((a % 2 != 0 && (ehPrimoA == 0)) && ehPrimoB) {
- vitoriasapo++;
- }
- else if ((b%2 != 0 && (ehPrimoB == 0)) && ehPrimoA) {
- vitoriashuas++;
- }
- }
- if (vitoriasapo > vitoriashuas) {
- printf("Sapo sopa esta de boa na lagoa!\n", vitoriasapo);
- }
- else if (vitoriashuas > vitoriasapo) {
- printf("Testemunhe a verdadeira forca!\n", vitoriashuas);
- }
- else {
- printf("Impending doom approaches...\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment