Pagini recente » Cod sursa (job #2032838) | Cod sursa (job #694424) | Cod sursa (job #1885309) | Cod sursa (job #3126184) | Cod sursa (job #1265109)
# include <bits/stdc++.h>
using namespace std;
ifstream fi("dame.in");
ofstream fo("dame.out");
const int nmax = 1e3 + 5;
int s[nmax];
int main(void)
{
int n;
fi>>n;
if (n == 2) return fo << "1\n1 1\n",0;
if (n == 3) return fo << "2\n1 1\n3 2\n",0;
fo << n << '\n';int p=0;
for (int i=2;i<=n;i+=2) s[++p]=i;
if (n % 6 == 3)
{
for (int i=1;i<p;++i) s[i]=s[i+1];s[p]=2;
}
for (int i=1;i<=p;++i) fo << i << ' ' << s[i] << '\n';
p=0;
for (int i=1;i<=n;i+=2) s[++p]=i;
if (n % 12 == 8) for (int i=2;i<=p;i+=2) swap(s[i],s[i-1]);
if (n % 12 == 2)
{
swap(s[1],s[2]);
for (int i=3;i<p;++i) s[i]=s[i+1];
s[p]=5;
}
if (n % 6 == 3)
{
for (int i=1,l=p-1;i<l;++i) s[i]=s[i+2];
s[p-1]=1;s[p]=3;
}
for (int i=1,l=n/2;i<=p;++i) fo << (l + i) << ' ' << s[i] << '\n';
return 0;
}