Codeforces Round #225 (Div. 2)A:Coder 解题报告
来源:互联网 发布:网络特性怎么做营销 编辑:程序博客网 时间:2024/06/06 03:06
题目地址:http://codeforces.com/contest/384/problem/A
大意:在一个n*n的棋盘上现在要在上面尽量多的放棋子,问满足不存在任意两个棋子相邻,最多能放多少个,并模拟出一种情况来。
思路:首先,最多的棋子数,要分别考虑n的奇偶性,通过画出前几个图形,可知道:n是奇数:能放n*n/2 ,n是偶数:能放(n*n+1)/2
至于模拟,我是用一种取巧的方法遍历得到的,具体的看代码·······
代码:
#include <iostream>using namespace std;int main(){ int n,m,l,p; cin>>n; if(n%2==1) cout<<(n*n+1)/2; else cout<<n*n/2; cout<<endl; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) if(i%2==j%2)cout<<"C"; //主要是这里,不懂的话就画下图··· else cout<<"."; cout<<endl; } //cout << "Hello world!" << endl; return 0;}
0 0
- Codeforces Round #225 (Div. 2)A:Coder 解题报告
- Codeforces Round #225 (Div. 2) A.Coder
- Codeforces Round #225 (Div. 2)A. Coder
- Codeforces Round #283 (Div. 2) 解题报告(A B C)
- Codeforces Round #284(Div.2) A,B,C解题报告
- Codeforces Round #285(Div.2) A,B,C 解题报告
- Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告
- 解题报告:Codeforces Round #364 (Div. 2) A~E
- 解题报告:Codeforces Round #371 (Div. 2) A~E
- 解题报告:Codeforces Round #421 (Div. 2) A-E
- Codeforces Round #149 (Div. 2)解题报告
- Codeforces Round #180 (Div. 2) 解题报告
- Codeforces Round #190 (Div. 2) 解题报告
- Codeforces Round #191 (Div. 2) 解题报告
- Codeforces Round #189 (Div. 2) 解题报告
- Codeforces Round #142 (Div. 2) 解题报告
- Codeforces Round #229 (Div. 2) 解题报告
- Codeforces Round #241 (Div. 2) 解题报告
- 黑马程序员_异常
- C++静态成员函数小结(转)
- 通用的权限设计(一)
- in loader dalvik.system.PathClassLoader
- Windows下配置Apache虚拟主题VirtualHost
- Codeforces Round #225 (Div. 2)A:Coder 解题报告
- Android UI画面显示问题需要给mtk提供的相关资讯?
- Java中的读写锁模拟实现
- Launcher源码浅析-----Launcher布局
- POJ2029--Get Many Persimmon Trees(枚举+二维树状数组)
- 编写你自己的单点登录(SSO)服务
- Android Provision (Setup Wizard)
- 如果用户没有登陆直接通过url访问其它页面的解决办法
- 2013-11-BASE64