fork download
  1. class XpLevel {
  2.  
  3. public static int levelToExp(int level) {
  4. return (int) Math.floor(1000 * Math.pow(level, 1.5));
  5. }
  6.  
  7. public static int expToLevel(int exp) {
  8. double level = Math.pow(exp / 1000.0, 2 / 3.0);
  9. int a = (int) Math.floor(level);
  10. int b = (int) Math.ceil(level);
  11. return levelToExp(b) > exp ? a : b;
  12. }
  13.  
  14. public static void main(String[] args) {
  15. for (int i = 0; i <= 20; i++) {
  16. int exp = levelToExp(i);
  17. System.out.print("Para o level " + i + " precisamos de " + exp + " EXP. ");
  18. int provaReal = expToLevel(exp);
  19. int antes = expToLevel(exp - 1);
  20. int depois = expToLevel(exp + 1);
  21. System.out.print((exp - 1) + " EXP = Level " + antes + ". ");
  22. System.out.print(exp + " EXP = Level " + provaReal + ". ");
  23. System.out.print((exp + 1) + " EXP = Level " + depois + ".");
  24. System.out.println();
  25. }
  26. }
  27. }
Success #stdin #stdout 0.1s 27852KB
stdin
Standard input is empty
stdout
Para o level 0 precisamos de 0 EXP. -1 EXP = Level 0. 0 EXP = Level 0. 1 EXP = Level 0.
Para o level 1 precisamos de 1000 EXP. 999 EXP = Level 0. 1000 EXP = Level 1. 1001 EXP = Level 1.
Para o level 2 precisamos de 2828 EXP. 2827 EXP = Level 1. 2828 EXP = Level 2. 2829 EXP = Level 2.
Para o level 3 precisamos de 5196 EXP. 5195 EXP = Level 2. 5196 EXP = Level 3. 5197 EXP = Level 3.
Para o level 4 precisamos de 8000 EXP. 7999 EXP = Level 3. 8000 EXP = Level 4. 8001 EXP = Level 4.
Para o level 5 precisamos de 11180 EXP. 11179 EXP = Level 4. 11180 EXP = Level 5. 11181 EXP = Level 5.
Para o level 6 precisamos de 14696 EXP. 14695 EXP = Level 5. 14696 EXP = Level 6. 14697 EXP = Level 6.
Para o level 7 precisamos de 18520 EXP. 18519 EXP = Level 6. 18520 EXP = Level 7. 18521 EXP = Level 7.
Para o level 8 precisamos de 22627 EXP. 22626 EXP = Level 7. 22627 EXP = Level 8. 22628 EXP = Level 8.
Para o level 9 precisamos de 27000 EXP. 26999 EXP = Level 8. 27000 EXP = Level 9. 27001 EXP = Level 9.
Para o level 10 precisamos de 31622 EXP. 31621 EXP = Level 9. 31622 EXP = Level 10. 31623 EXP = Level 10.
Para o level 11 precisamos de 36482 EXP. 36481 EXP = Level 10. 36482 EXP = Level 11. 36483 EXP = Level 11.
Para o level 12 precisamos de 41569 EXP. 41568 EXP = Level 11. 41569 EXP = Level 12. 41570 EXP = Level 12.
Para o level 13 precisamos de 46872 EXP. 46871 EXP = Level 12. 46872 EXP = Level 13. 46873 EXP = Level 13.
Para o level 14 precisamos de 52383 EXP. 52382 EXP = Level 13. 52383 EXP = Level 14. 52384 EXP = Level 14.
Para o level 15 precisamos de 58094 EXP. 58093 EXP = Level 14. 58094 EXP = Level 15. 58095 EXP = Level 15.
Para o level 16 precisamos de 64000 EXP. 63999 EXP = Level 15. 64000 EXP = Level 16. 64001 EXP = Level 16.
Para o level 17 precisamos de 70092 EXP. 70091 EXP = Level 16. 70092 EXP = Level 17. 70093 EXP = Level 17.
Para o level 18 precisamos de 76367 EXP. 76366 EXP = Level 17. 76367 EXP = Level 18. 76368 EXP = Level 18.
Para o level 19 precisamos de 82819 EXP. 82818 EXP = Level 18. 82819 EXP = Level 19. 82820 EXP = Level 19.
Para o level 20 precisamos de 89442 EXP. 89441 EXP = Level 19. 89442 EXP = Level 20. 89443 EXP = Level 20.