Advertisement
mantertius

pokemon_v3.c

Dec 10th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.32 KB | None | 0 0
  1. //VERSÃO 3.2
  2. //https://thehuxley.com/problem/1250/
  3. #include <stdio.h>
  4. #include <string.h>
  5. //vida V
  6. //dano inicial inteiro D.
  7. //A batalha termina quando um dos pokemons perde toda sua vida.
  8. //normal = D_enemy_atual
  9. //especial →  D_new = D_0 + 50.
  10.  
  11. //Bezaliel vai atacar todos os turnos até derrotar o inimigo ou perder tentando
  12. //Clodes vai usar a habilidade de incrementar o dano de seu pokemon até chegar num ponto que não possa mais perder(qual o ponto?) e só então começar a atacar
  13. //Considere que o pokemon de Clodes é o mais rápido, ou seja, ele sempre ataca primeiro
  14. /*3
  15. 100 500 20 50
  16. 1000 1000 20 30
  17. 10000 10500 10 50*/
  18.  
  19. //v1,d1 CLODES
  20. //v2,d2 BEZALIEL
  21. #define clo 13
  22. #define bez 31
  23.  
  24.  
  25.  
  26. int hp_clodes_turno_n(int turno_n, int dano_bez_inicial, int hp_clodes_inicial)
  27. {
  28.     int hp_clodes = hp_clodes_inicial - dano_bez_inicial*turno_n;
  29.     return hp_clodes;
  30. }
  31. int dano_clodes_turno_n(int turno_n, int dano_clo_inicial)
  32. {
  33.     int dmg_clodes = (dano_clo_inicial + (50*turno_n));
  34.     return dmg_clodes;
  35. }
  36.  
  37. int turnos_necessarios_para_clodes_vencer(int hp_clodes,int hp_bezaliel,int dano_clodes_inicial,int dano_bezaliel)
  38. {  
  39.     int turnos = (hp_bezaliel-dano_clodes_inicial)/50;
  40.     return turnos;    
  41. }
  42.  
  43. int turnos_necessarios_para_bezaliel_vencer (int hp_clodes,int dano_bezaliel)
  44. {
  45.     int turnos = hp_clodes/dano_bezaliel;
  46.     return turnos;
  47. }
  48.  
  49. int turns_needed(int v1,int v2,int d1,int d2)
  50. {
  51.     int beza = turnos_necessarios_para_bezaliel_vencer(v1,d2);
  52.     int clod = turnos_necessarios_para_clodes_vencer(v1,v2,d1,d2);
  53.     //printf("precisa de %d pra bez ganhar e %d pra clod ganhar\n",beza,clod);
  54.     if (clod > beza)
  55.     {
  56.         return clo;
  57.     }
  58.     else
  59.     {
  60.         return beza;
  61.     }
  62.    
  63. }
  64.  
  65. int battle(int v1,int v2,int d1,int d2, int round_num)
  66. {
  67.     //turno(v1,v2,d1,d2,round_num);
  68.     //turns_needed(v1,v2,d1,d2);
  69.     int d1_new = d1+50;
  70.     int v1_new = (v1 - d2);
  71.     if (v1<0 && v2>0)
  72.     {
  73.         return bez;
  74.     }
  75.     if (v1>0 && v2<0)
  76.     {
  77.         return clo;
  78.     }
  79.    
  80.     if ((v2/d1_new < v1/d2 && d2<v1) || (v2 <= 0) || (d1_new >= v2))
  81.     {
  82.         //printf("~~~~primeiro if\n");
  83.         return clo;
  84.     }
  85.     else if (v1 <= 0 || turnos_necessarios_para_bezaliel_vencer(v1,d2) == 0)
  86.     {
  87.         //printf("~~~~segundo if\n");
  88.         return bez;
  89.     }
  90.     else
  91.     {
  92.        // printf("~~~~else\n");
  93.        
  94.         return battle(v1_new,v2,d1_new,d2,round_num+1);
  95.     }
  96.    
  97.    
  98. }
  99. int turno(int v1,int v2,int d1,int d2, int round_num)
  100. {
  101.     printf("no turno %d temos:",round_num);
  102.     printf("DMG_CLO:[%d], HP_CLO:[%d]\n", dano_clodes_turno_n(round_num, d1), hp_clodes_turno_n(round_num, d2, v1));
  103. }
  104. int stat_scan (int n_battles) //recebe os inputs baseado no numero de batalhas
  105. {
  106.     if (n_battles <= 0)
  107.     {
  108.         return 42;
  109.     }
  110.     int v1;
  111.     int v2;
  112.     int d1;
  113.     int d2;
  114.     scanf("%d",&v1);
  115.     scanf("%d",&v2);
  116.     scanf("%d",&d1);
  117.     scanf("%d",&d2);
  118.    
  119.     int resultado = battle(v1,v2,d1,d2,1); //resultado da batalha
  120.  
  121.     if (resultado == bez)
  122.     {
  123.         printf("Bezaliel\n");
  124.     }
  125.     if (resultado == clo)
  126.     {
  127.         printf("Clodes\n");
  128.     }
  129.  
  130.     stat_scan(n_battles-1);
  131.    
  132. }
  133. int main ()
  134. {
  135.     int n_battles;
  136.     scanf("%d",&n_battles);
  137.     stat_scan(n_battles);
  138.     return 0;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement