a53

Submultimi2

a53
Apr 3rd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int n, k, r, ak, bk, sumak, ar, br, sumar, i, j, l=0;
  5. int main()
  6. {
  7. cin>>n>>k>>r;
  8. if(n%2==0)
  9. cout<<n/2<<'\n';
  10. else
  11. cout<<(n-1)/2<<'\n';
  12. ak=(k*(k-1))/2;
  13. bk=ak+k-1;
  14. ar=(r*(r-1))/2;
  15. br=ar+r-1;
  16. sumak=((ak+bk)*k)/2;
  17. sumar=((ar+br)*r)/2;
  18. cout<<(sumak+sumar)/(k+r)<<'\n';
  19. i=ar;
  20. j=br;
  21. while(i<j)
  22. {
  23. cout<<i<<" ";
  24. i++;
  25. cout<<i<<" ";
  26. i++;
  27. if(j>i)
  28. cout<<j<<" ", j--;
  29. }
  30. if(i==j)
  31. cout<<i<<" ";
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment