Pagini recente » Cod sursa (job #158777) | Cod sursa (job #195126) | Cod sursa (job #2356094) | Cod sursa (job #736850) | Cod sursa (job #2664667)
#include <bits/stdc++.h>
using namespace std;
ifstream f("dame.in");
ofstream g("dame.out");
bool colon[1005];
bool mat[1005][1005];
int dame;
int n;
int main()
{
f >> n;
dame = n;
int lin = 1;
int col = 2;
while (dame!=0) {
while (col <= n) {
mat[lin][col]=1;
colon[col]=1;
lin++;
col+=2;
dame--;
}
col = 1;
while (colon[col]==1) {
col++;
}
}
if (n>3) {
g << n <<'\n';
for (int i=1;i<=n;i++) {
for (int j=1;j<=n;j++) {
if (mat[i][j]==1) {
g << i << " " << j << '\n';
}
}
}
}
else if (n<=2) {
g << 1 <<'\n' << 1 << " " <<1;
}
else {
g << 2 << '\n' << 1 << " " << 1 << '\n' << 2 << " " << 3;
}
return 0;
}