code forces 1173 B. Nauuo and Chess

本文链接:https://www.cnblogs.com/blowhail/p/10991237.html

B. Nauuo and Chess  原题链接:http://codeforces.com/contest/1173/problem/B

题目大意: 在一个m x m的棋盘中放n个棋子,满足 |rirj|cicj≥ |ij|   |ri−rj| + |ci−cj| ≥ |i−j|   (r为行,c为列)

大致思路:找规律之后可以发现,斜对角线上可以放的最大棋子数满足1 3 5 7 ....

如图

 

因此,我们可以这样放棋子:

代码如下:

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <algorithm>
 4 #include <string>
 5 #include <cstring>
 6 #include <cmath>
 7 #define ll long long
 8 using namespace std;
 9 
10 int main ()
11 {
12     int i,t,m,n,u,sum,maxs,mins,x,y,z;
13     scanf("%d",&n);
14     m=n/2+1; //根据规律,直接算出棋盘大小
15     printf("%d\n",m);
16     for(i=1;i<=m;++i)
17         printf("%d %d\n",1,i);
18     for(i=2;i<=n-m+1;++i)
19         printf("%d %d\n",i,m);
20 
21     return 0;
22 }

 

转载于:https://www.cnblogs.com/blowhail/p/10991237.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值