problem 1178
来源:互联网 发布:falcon python 编辑:程序博客网 时间:2024/06/06 01:48
稍微推一下公式就可以了。 Accepted 1178 C 00:00.01 392K
#include<stdio.h>
void solve(int n)
{
int s = n / 4 + 1;
if (n % 4 == 0) s--;
int a = s * 4;
int i;
for (i = 1; i <= s; i++)
{
int x = a - 2 * i + 2;
int y = 2 * i - 1;
if (!(x > n && y > n))
{
printf("Sheet %d, front: ",i);
if (x > n) printf("Blank, ");
else printf("%d, ",x);
if (y > n) printf("Blank ");
else printf("%d/n",y);
}
x = 2 * i;
y = a - 2 * i + 1;
if (!(x > n && y > n))
{
printf("Sheet %d, back : ",i);
if (x > n) printf("Blank, ");
else printf("%d, ",x);
if (y > n) printf("Blank/n");
else printf("%d/n",y);
}
}
}
void main()
{
#ifndef ONLINE_JUDGE
freopen("1178.txt","r",stdin);
#endif
int n;
while(scanf("%d",&n) != EOF && n != 0)
{
printf("Printing order for %d pages:/n",n);
solve(n);
}
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
}
void solve(int n)
{
int s = n / 4 + 1;
if (n % 4 == 0) s--;
int a = s * 4;
int i;
for (i = 1; i <= s; i++)
{
int x = a - 2 * i + 2;
int y = 2 * i - 1;
if (!(x > n && y > n))
{
printf("Sheet %d, front: ",i);
if (x > n) printf("Blank, ");
else printf("%d, ",x);
if (y > n) printf("Blank ");
else printf("%d/n",y);
}
x = 2 * i;
y = a - 2 * i + 1;
if (!(x > n && y > n))
{
printf("Sheet %d, back : ",i);
if (x > n) printf("Blank, ");
else printf("%d, ",x);
if (y > n) printf("Blank/n");
else printf("%d/n",y);
}
}
}
void main()
{
#ifndef ONLINE_JUDGE
freopen("1178.txt","r",stdin);
#endif
int n;
while(scanf("%d",&n) != EOF && n != 0)
{
printf("Printing order for %d pages:/n",n);
solve(n);
}
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
}
- problem 1178
- problem
- Problem
- problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- 正则表达式30分钟入门教程
- 了解使用ptr_fun、mem_fun和mem_fun_ref的原因1(Effective stl 条款41)
- linux中修改root口令
- 庐山之行小记
- 微软跨平台Flash杀手即将到来:Sliverlight 银光~
- problem 1178
- 语句作用域
- SQL初学者可以看看的一些简单SQL语句
- 警报器
- SOA 背后的管理哲学
- 消防按钮
- 从乐高玩具到丽江古城--理解SOA概念的三个比喻
- 获取表中字段的信息
- 警灯