Pagini recente » Cod sursa (job #2498182) | Cod sursa (job #729474) | Cod sursa (job #209291) | Cod sursa (job #2626171) | Cod sursa (job #2770774)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("dame.in");
ofstream fout("dame.out");
vector<pair<int, int> > afis;
const int NMAX(1005);
bool mat[NMAX][NMAX], lib2[NMAX];
int n;
int main()
{
fin >> n;
int i, j;
if(n % 2 == 1)
i = n, j = 1;
else i = n - 1, j = 1;
afis.push_back({i, j});
lib2[i] = 1;
while(i != 1)
{
i -= 2;
j++;
afis.push_back({i, j});
lib2[i] = 1;
}
for(; j <= n; ++j)
{
int x = n;
while(x >= 1 && lib2[x] == 1)
--x;
if(x >= 1)
{
lib2[x] = 1;
afis.push_back({x, j});
}
}
fout << afis.size() << '\n';
for(auto it: afis)
fout << it.first << ' ' << it.second << '\n';
return 0;
}