fork download
  1. #include <stdio.h>
  2.  
  3. char *z[] = {
  4. "Normal","Fighting","Flying","Poison","Ground","Rock","Bug","Ghost",
  5. "Steel","Fire","Water","Grass","Electric","Psychic","Ice","Dragon","Dark","Fairy"
  6. };
  7.  
  8. *y[]={"8(;","i56n9(q@wyD","j8o;t?","678:)tz","#ln9qr>u","4k7o;rw","456:;<tvyD","!pvC","n;<=?wz","8oq<=twB","mnr=>B","56mn9;<s>B","k%s>?B","jl;@1","km;<=tAx",";x2","4pvCD","j6;<xy"};float f(int**s){int k[3]={},i=54,j;float f=1;for(;i--;s[i%3]&&!strcmp(z[i/3],s[i%3])?k[i%3]=i/3:0);for(char*t=y[*k];i=*t-33,*t++;)for(j=0;++j<3;)f*=i%18-k[j]?1:i/18/2.;return f;}
  9.  
  10. char *tests[]= {
  11. "Ground", "Flying", NULL,
  12. "Normal", "Rock", "Steel",
  13. "Normal", "Rock", NULL,
  14. "Normal", "Normal", NULL,
  15. "Water", "Fire", NULL,
  16. "Flying", "Fighting", "Bug",
  17. "Normal", "Ice", "Ground",
  18. "Fire", "Water", "Rock",
  19. "Fire", "Rock", NULL,
  20. "Water", "Ice", "Ghost",
  21. "Water", "Ghost", NULL,
  22. "Dragon", "Dragon", "Steel",
  23. "Dragon", "Dragon", NULL,
  24. NULL
  25. };
  26.  
  27.  
  28. int main(int argc,char **argv) {
  29. if(argc>2) {
  30. char *s[3]={argv[1], argv[2], argv[3]};
  31. printf("%.2f\n", f(s));
  32. } else {
  33. for(int i=0;tests[i];i+=3) {
  34. char *s[]={tests[i], tests[i+1], tests[i+2]};
  35. printf("%.2f\n", f(s));
  36. }
  37. }
  38. }
Success #stdin #stdout 0s 4392KB
stdin
Standard input is empty
stdout
0.00
0.25
0.50
1.00
2.00
4.00
1.00
0.25
0.50
1.00
1.00
1.00
2.00