Advertisement
Guest User

buzibence

a guest
Mar 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <math.h>
  4. using namespace std;
  5. // 1/2,2/3,3,3/4,4,4,4...
  6. ifstream f("szam.in");
  7. ofstream g("szam.out");
  8. int gy[101];
  9. unsigned long long N;// legtobb 18;
  10. int main()
  11. {
  12. f>> N;int M=N;
  13. cout << "N=" << N << endl;
  14. for(int i=1; N>0; i++)
  15. {
  16. for(int j=1;j<=i && N>0;j++)
  17. {
  18. g << j << " ";gy[j]++;
  19. N--;
  20. }
  21. for(int j=i-1; j>=1 && N>0;j--)
  22. {
  23. g << j << " ";gy[j]++;
  24. N--;
  25. }
  26. g<<endl;
  27. }
  28. f.close();g.close();
  29. int gyok=(int)(sqrt(M))+1;
  30. for(int i=1;i<=gyok;i++)
  31. cout<<i<<" "<<gy[i]<<endl;
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement