Advertisement
a53

wisp_7p

a53
May 13th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #define ULL unsigned long long
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. ifstream f("wisp.in");
  9. ULL n,k;
  10. f>>n>>k;
  11. f.close();
  12. ULL s=1,sol=1;
  13. if(n%2)
  14. for(ULL i=1;i<=n/2+2;i+=2)
  15. s+=2*(n-i),sol+=s,cout<<s<<'\n',s+=2*(n-i),sol+=s,cout<<s<<'\n';
  16. else
  17. {
  18. for(ULL i=1;i<=n/2;i+=2)
  19. s+=2*(n-i),sol+=s,cout<<s<<'\n',s+=2*(n-i),sol+=s,cout<<s<<'\n';
  20. sol+=s+2;
  21. }
  22. sol+=n*(k-1); /// Corectez suma pentru k>1
  23. ofstream g("wisp.out");
  24. g<<sol<<'\n';
  25. g.close();
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement