Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <math.h>
- using namespace std;
- // 1/2,2/3,3,3/4,4,4,4...
- ifstream f("szam.in");
- ofstream g("szam.out");
- int gy[101];
- unsigned long long N;// legtobb 18;
- int main()
- {
- f>> N;int M=N;
- cout << "N=" << N << endl;
- for(int i=1; N>0; i++)
- {
- for(int j=1;j<=i && N>0;j++)
- {
- g << j << " ";gy[j]++;
- N--;
- }
- for(int j=i-1; j>=1 && N>0;j--)
- {
- g << j << " ";gy[j]++;
- N--;
- }
- g<<endl;
- }
- f.close();g.close();
- int gyok=(int)(sqrt(M))+1;
- for(int i=1;i<=gyok;i++)
- cout<<i<<" "<<gy[i]<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement