Algorithm
Problem Name: 2 AD-HOC - beecrowd | 1836
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1836
Pokémon!
Por Edson Alves, Faculdade UnB Gama Brazil
Timelimit: 1
In the first generation, the creatures from the Pokémon game have four basic attributes: hit points (HP), attack (AT), defense (DF) and speed (SP). These attributes increased as the pokémon gained experience levels winning battles or using special itens.
For each level (from 1 to 99) the value of the attributes can be computed by the following expressions:
e
The EV and IV values differentiate two pokémons of same kind, making both evolutions differ. Each attribute must have a integer value: the decimal value must be discarded after the fraction computation.
Given a pokémon, its basic attributes values and level, compute the attributes values according to the expressions.
Input
The input consists of a series of test cases. The number of test cases T (T ≤ 1.000) is given in the first line of the input.
Each test case is composed by five lines. The first one contains the pokémon name P and its level L (1 ≤ L ≤ 99), separated by a single space. The pokémon's name has only alphanumeric characteres.
The following lines have three integers each: BS (1 ≤ BS ≤ 255), IV (1 ≤ IV ≤ 15) e EV (1 ≤ EV ≤ 262.140), separated by a single space, for each one of the attributes, in this order: HP, AT, DF e SP.
Output
For each test case the output is formed by five messages, one per line:
- Caso #t: P nivel L
- HP: HPC
- AT: ATC
- DF: DFC
- SP: SPC
Input Samples | Output Samples |
4 Pikachu 81 35 7 22850 55 8 23140 30 13 17280 90 5 24795 Bulbasaur 50 45 9 20000 49 12 40000 49 3 60000 45 8 10000 Charmander 30 39 5 35000 52 14 60000 43 7 38000 65 15 200000 Squirtle 90 44 10 180000 48 2 220000 65 11 175000 43 8 192000 |
Caso #1: Pikachu nivel 81 HP: 189 AT: 137 DF: 101 SP: 190 Caso #2: Bulbasaur nivel 50 HP: 131 AT: 91 DF: 87 SP: 70 Caso #3: Charmander nivel 30 HP: 80 AT: 62 DF: 49 SP: 86 Caso #4: Squirtle nivel 90 HP: 292 AT: 200 DF: 235 SP: 195 |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
#include <math.h>
int calcHP(unsigned nivel, unsigned base, unsigned gene, unsigned batalhas);
int calcS(unsigned nivel, unsigned base, unsigned gene, unsigned batalhas);
void main ()
{
unsigned gene, batalhas, base, nivel;
unsigned short casos;
char pokemon[1000], qtsCasos = 1;
scanf("%hu", &casos);
while (casos--)
{
scanf(" %s %u %u %u %u", pokemon, &nivel, &base, &gene, &batalhas);
printf("Caso #%hu: %s nivel %u\n", qtsCasos++, pokemon, nivel);
printf("HP: %d\n", calcHP(nivel, base, gene, batalhas));
scanf("%u %u %u", &base, &gene, &batalhas);
printf("AT: %d\n", calcS(nivel, base, gene, batalhas));
scanf("%u %u %u", &base, &gene, &batalhas);
printf("DF: %d\n", calcS(nivel, base, gene, batalhas));
scanf("%u %u %u", &base, &gene, &batalhas);
printf("SP: %d\n", calcS(nivel, base, gene, batalhas));
}
}
int calcHP(unsigned nivel, unsigned base, unsigned gene, unsigned batalhas)
{
double s;
s = (((gene + base + (sqrt(batalhas)/8) + 50) * nivel)/50) + 10;
return (int)s;
}
int calcS(unsigned nivel, unsigned base, unsigned gene, unsigned batalhas)
{
double s;
s = (((gene + base + (sqrt(batalhas)/8)) * nivel)/50) + 5;
return (int)s;
}
Copy The Code &
Try With Live Editor
Input
Pikachu 81
35 7 22850
55 8 23140
30 13 17280
90 5 24795
Bulbasaur 50
45 9 20000
49 12 40000
49 3 60000
45 8 10000
Charmander 30
39 5 35000
52 14 60000
43 7 38000
65 15 200000
Squirtle 90
44 10 180000
48 2 220000
65 11 175000
43 8 192000
Output
HP: 189
AT: 137
DF: 101
SP: 190
Caso #2: Bulbasaur nivel 50
HP: 131
AT: 91
DF: 87
SP: 70 Caso #3: Charmander nivel 30
HP: 80
AT: 62
DF: 49
SP: 86
Caso #4: Squirtle nivel 90
HP: 292
AT: 200
DF: 235
SP: 195
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int main()
{
string pk;
int n;
int l;
int bs, ev, iv;
int caso = 1;
cin >> n;
while (n--)
{
cin >> pk >> l;
cout << "Caso #" << caso++ << ": ";
cout << pk << " nivel " << l << '\n';
cin >> bs >> iv >> ev;
cout << "HP: " << (int)((((iv + bs + sqrt(ev)/8. + 50) * l) / 50) + 10) << '\n';
cin >> bs >> iv >> ev;
cout << "AT: " << (int)((((iv + bs + sqrt(ev)/8.) * l) / 50) + 5) << '\n';
cin >> bs >> iv >> ev;
cout << "DF: " << (int)((((iv + bs + sqrt(ev)/8.) * l) / 50) + 5) << '\n';
cin >> bs >> iv >> ev;
cout << "SP: " << (int)((((iv + bs + sqrt(ev)/8.) * l) / 50) + 5) << '\n';
}
}
Copy The Code &
Try With Live Editor
Input
Pikachu 81
35 7 22850
55 8 23140
30 13 17280
90 5 24795
Bulbasaur 50
45 9 20000
49 12 40000
49 3 60000
45 8 10000
Charmander 30
39 5 35000
52 14 60000
43 7 38000
65 15 200000
Squirtle 90
44 10 180000
48 2 220000
65 11 175000
43 8 192000
Output
HP: 189
AT: 137
DF: 101
SP: 190
Caso #2: Bulbasaur nivel 50
HP: 131
AT: 91
DF: 87
SP: 70 Caso #3: Charmander nivel 30
HP: 80
AT: 62
DF: 49
SP: 86
Caso #4: Squirtle nivel 90
HP: 292
AT: 200
DF: 235
SP: 195