Magnet particules in boxes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #include <bits/stdc++.h> using namespace std; class Magnets { public: static double doubles(int maxk, int maxn); };
double Magnets::doubles(int maxk, int maxn) { double res = 0.; auto v = [](double i, double j) { return 1. / i / pow(j+1,2*i); }; for(int i = 1; i <= maxk; i++) { for(int j = 1; j <= maxn; j++) { res += v(i,j); } } return res; }
|