Advertisement
a53

suminvdiv

a53
Dec 30th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <fstream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. unsigned int n,d;
  8. double S;
  9. ifstream f("suminvdiv.in");
  10. ofstream g("suminvdiv.out");
  11. while(f>>n)
  12. {
  13. S=0;
  14. for(d=1;d*d<n;++d)
  15. if(n%d==0)
  16. S+=1.0/d+1.0/(n/d);
  17. if(d*d==n)
  18. S+=1.0/d;
  19. g<<fixed<<setprecision(2)<<S<<' ';
  20. }
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement