Problem_A(592A):

题意:

  在一个8*8的棋盘上有黑白两种棋子,'W'代表白色,'B'代表黑色。

  玩家A执白子,先走。 白子只能向上走,黑子只能向下走。如果有障碍物则不能走, 比如白色的上方有一个黑子,那么白子不能走。

  谁先走到边界谁就赢了。 求解谁会赢

思路:

  白子只能往上走, 黑子只能往下走。

  所以只要找出最上面的白子和最下面的白子, 求距离边界最小值就可以了。

代码:

  

 #include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 10
#define MAXM 100
#define dd {cout<<"debug"<<endl;}
#define pa {system("pause");}
#define p(x) {printf("%d\n", x);}
#define pd(x) {printf("%.7lf\n", x);}
#define k(x) {printf("Case %d: ", ++x);}
#define s(x) {scanf("%d", &x);}
#define sd(x) {scanf("%lf", &x);}
#define mes(x, d) {memset(x, d, sizeof(x));}
#define do(i, x) for(i = 0; i < x; i ++)
#define dod(i, x, l) for(i = x; i >= l; i --)
#define doe(i, x) for(i = 1; i <= x; i ++)
int n = ;
int row[MAXN][MAXN];
int read_ch()
{
char ch;
while(ch = getchar())
{
if(ch == 'B') return ;
if(ch == 'W') return ;
if(ch == '.') return ;
}
} int main()
{
mes(row, );
for(int i = ; i <= n; i ++)
for(int j = ; j <= n; j ++)
row[i][j] = read_ch(); int min_a = INF, min_b = INF; for(int j = ; j <= n; j ++)
{
for(int i = ; i <= n; i ++)
{
if(row[i][j] == ) break;
if(row[i][j] == )
{
min_a = min(min_a, i - );
break;
}
}
for(int i = n; i >= ; i --)
{
if(row[i][j] == ) break;
if(row[i][j] == )
{
min_b = min(min_b, n - i);
break;
}
}
}
printf("%c\n", min_a <= min_b ? 'A' : 'B');
return ;
}

Problem_B(592B):

题意:

  给n个点, 依旧如下的规则划线:

    1:先按顺时针将所有的点标号 1~n

    2:从第一个点开始, 对其他n-1个点做一条射线

    3:如果射线延长的过程中遇到其他线段, 则停止延长。

  求这个n-1多边形内的区域被分成了多少块。

思路:

  手动模拟一下n = 4和n = 6的情况,就能发现一个规律:

    第一个点将区域划分成了 n - 2块区域。

    第二个点又增加了 n - 3个区域。

    第三个点增加了 n - 4 个区域。

    .....

    第n - 1个点增加了n - (n - 1) 块区域。

    第n个点增加了n - 2块区域。

  然后就能得到一个式子:

    Sn = n - 2 + n - 3 + n - 4 + ... + n - (n - 1) + n - 2

       = n * n - (2 + 3 + 4 + ... + (n - 1)) - 2

         = n * n - (1 + 2 + 3 + ... + (n - 1)) - 1

       = n * n - (1 + (n - 1)) * (n - 1) / 2 - 1

  So 答案就出来了。

代码:

  

 #include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 1000000
#define MAXM 100
#define dd {cout<<"debug"<<endl;}
#define pa {system("pause");}
#define p(x) {printf("%d\n", x);}
#define pd(x) {printf("%.7lf\n", x);}
#define k(x) {printf("Case %d: ", ++x);}
#define s(x) {scanf("%d", &x);}
#define sd(x) {scanf("%lf", &x);}
#define mes(x, d) {memset(x, d, sizeof(x));}
#define do(i, x) for(i = 0; i < x; i ++)
#define dod(i, x, l) for(i = x; i >= l; i --)
#define doe(i, x) for(i = 1; i <= x; i ++)
LL n;
LL get_ans(LL x)
{
return (n - ) + * (n - ) + (n - ) * (n - );
} int main()
{
scanf("%I64d", &n);
printf("%I64d\n", get_ans(n));
return ;
}

Codeforces Round #328 div2的更多相关文章

  1. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  2. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  3. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  4. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  5. Codeforces Round #361 div2

    ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...

  6. Codeforces Round #626 Div2 D,E

    比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...

  7. Codeforces Round #328(Div2)

    CodeForces 592A 题意:在8*8棋盘里,有黑白棋,F1选手(W棋往上-->最后至目标点:第1行)先走,F2选手(B棋往下-->最后至目标点:第8行)其次.棋子数不一定相等,F ...

  8. CodeForces Round 192 Div2

    This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...

  9. Codeforces Round #328 (Div. 2) D. Super M

    题目链接: http://codeforces.com/contest/592/problem/D 题意: 给你一颗树,树上有一些必须访问的节点,你可以任选一个起点,依次访问所有的必须访问的节点,使总 ...

随机推荐

  1. mvn打包

    mvn install -DskipTests mvn install -Dmaven.test.skip=true

  2. 局域网内sqldeveloper客户端连接oracle服务器

    1:输入参数 输入连接名(随便写) 用户名:system/tiger/sys或者是创建的用户 口令:设置的口令 主机名:连接的数据库所在的ip 端口:默认是1521 sid:orcl安装时自己设置的 ...

  3. [转]Spring数据库读写分离

    数据库的读写分离简单的说是把对数据库的读和写操作分开对应不同的数据库服务器,这样能有效地减轻数据库压力,也能减轻io压力. 主(master)数据库提供写操作,从(slave)数据库提供读操作,其实在 ...

  4. 目前电脑的硬件尺寸参数,计划弄个小一些的ATX机箱

    显卡:讯景R9 370x 尺寸:234×115×39mm 主板:技嘉GA-970A-DS3P 尺寸: 30.5X21.5 cm

  5. 为什么margin-top不是作用于父元素

    为什么margin-top不是作用于父元素:建议:尽可能的手写代码,可以有效的提高学习效率和深度.至于margin-top属性的基本用法再简单不过,那就是设置一个对象的上外边距,看下面的代码实例: & ...

  6. 基于spark实现表的join操作

    1. 自连接 假设存在如下文件: [root@bluejoe0 ~]# cat categories.csv 1,生活用品,0 2,数码用品,1 3,手机,2 4,华为Mate7,3 每一行的格式为: ...

  7. Activiti 工作流会签开发设计思路

    http://man1900.iteye.com/blog/1607753 在流程业务管理中,任务是通常都是由一个人去处理的,而多个人同时处理一个任务,这种任务我们称之为会签任务.这种业务需求也很常见 ...

  8. 序列化和反序列化(C#)

    有时候我们希望把类的实例保存下来,以便以后的时候用.一个直观的方法就是StreamWriter把类写成一行,用\t分隔开每个属性,然后用StreamReader读出来. 但是这样太麻烦,代码行数较多, ...

  9. 【Android】关于pix,dip,dip,sp等相关概念

    1.px (pixels)像素 – 是像素,就是屏幕上实际的像素点单位. dip或dp (device independent pixels)设备独立像素, 与设备屏幕有关. sp (scaled p ...

  10. windows下用过VMware安装MAC OS X苹果系统

    vmware怎么安装os x10.9?vmware 10安装mac os 10.9教程详解 来源:互联网 作者:佚名 时间:10-30 13:50:20 [大 中 小] VMWare 虚拟机可以使你在 ...