// first point is strange on Redhat9 gcc3.2 compiler. one digit missing?
#include <iostream>
#include <cmath>
#include <cstdlib>
//using namespace std;
//#define D 0.306
int main(int argc, char *argv[])
{
  if(argc!=3) {
    std::cout << "Usage: weizsacker IA IZ \n"<<"weizsacker 235 92\n";
    return 1;
  }
  

  int ia=atoi(argv[1]);
  int iz=atoi(argv[2]);
  double A=float(ia);
  
  double Cv=15.56;
  double Cs=17.23;
  double Csym=23.285;
  double Cc=0.697;
  int izc=round(A/(2.+0.5*Cc/Csym*pow(A,(2./3.))));//most stable Z
  //int izc=round(A/(2.+0.015*pow(A,(2./3.))));//most stable Z in Yagi
  double Z=float(iz);
  double Ev=Cv*A;
  double Es=-1.*Cs*pow(A,(2./3.));
  double Esym=-1.*Csym*pow((A-2*Z),2.)/A;
  double Ec = -1.*Cc*Z*Z/pow(A,(1./3.));
  double Edelta=0.;
  if(iz % 2 ==0 && ia % 2 == 0){
    Edelta=12./sqrt(A);
  }
  if(iz % 2 ==1 && ia % 2 == 1){
    Edelta=-1.*12./sqrt(A);
  }
  double Eb=Ev+Es+Ec+Esym+Edelta;
  std::cout << "stable Z: "<< izc << " Eb: " << Eb << " Ev: " << Ev << std::endl;
  std::cout << " Es: " << Es << " Ec: " << Ec;
  std::cout << " Esym: " << Esym << " Edelta: " << Edelta;

  return 0;
}