Advertisement
a53

smin

a53
Sep 15th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <fstream>
  2. #include <cmath>
  3. #include <iomanip>
  4. #define MAX1 20
  5. #define MAX2 1<<20
  6. #define INFINIT 1E20
  7. using namespace std;
  8. ifstream f("smin.in");
  9. ofstream g("smin.out");
  10. double s[MAX2];
  11. int i,j,k,l,m,n,z;
  12. double tr;
  13. struct Punct
  14. {
  15. int x,y;
  16. } p[MAX1];
  17.  
  18. double Aria(Punct p1,Punct p2,Punct p3) /// dublul ariei triunghiului
  19. {
  20. return (p1.x-p2.x)*(p1.y+p2.y)+(p2.x-p3.x)*(p2.y+p3.y)+(p3.x-p1.x)*(p3.y+p1.y);
  21. }
  22.  
  23. int main()
  24. {
  25. f>>n;
  26. for(i=0;i<n;++i)
  27. f>>p[i].x>>p[i].y;
  28. m=1<<n;
  29. s[0]=0.0;
  30. for(i=1;i<m;++i)
  31. s[i]=INFINIT;
  32. for(i=0;i<m;++i)
  33. for(j=0;j<n;++j)
  34. for(k=j+1;k<n;++k)
  35. for(l=k+1;l<n;++l)
  36. {
  37. z=i|(1<<j)|(1<<k)|(1<<l);
  38. tr=fabs(Aria(p[j],p[k],p[l]));
  39. if (s[z]>s[i]+tr)
  40. s[z]=s[i]+tr;
  41. }
  42. g<<s[m-1]*0.5<<'\n';
  43. f.close();
  44. g.close();
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement