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. 关于Eclispe插件开发起步(一)

    Eclipse中三个最吸引人的地方是: 第一是它创新性的图形API,就是SWT/JFace. 第二是它的插件机制. 第三个是利用它的插件机制开发众多功能强大的插件. 插件成就了Eclipse的今天.E ...

  2. Redis Cluster踩过的坑

    Redis Cluster踩过的坑请参考如下链接:http://www.iteye.com/blogs/subjects/Redis_Cluster_Devops

  3. HTTP层 —— 控制器

    1.简介 将所有的请求处理逻辑都放在单个 routes.php 中显然是不合理的,你也许还希望使用控制器类组织管理这些行为.控制器可以将相关的 HTTP 请求封装到一个类中进行处理.通常控制器存放在 ...

  4. select2的基本用法

    公司有个项目需要用到类似百度搜索功能的下拉框,自然想到使用select2. 先看下select2的效果图,如下: 下来简单介绍下这个控件的基本用法,主要简单介绍下远程加载数据: 1.首先引入需要的文件 ...

  5. SQL-学习使用FOR XML PATH

    前言:本人SQL技术很烂,然后工作时间也不久,许多东西都还在学习中,说的不好的地方尽请谅解. 首先跟大家说一下我今天遇到的问题吧. 查出的数据有三列,第一列存放的是32位的GUID,Res_Name存 ...

  6. C#学习笔记5:数据类型与进制转换

    1.C#: 8种整形类型.2种用于科学计算的二进制浮点类型.1种用于金融计算的十进制浮点类型. 2.Decimal是一种特殊的浮点类型,能够存储大数字而无表示错误. 常用于货币计算.在表示的所有十进制 ...

  7. 转:EF调用存储过程、函数

    EF调用存储过程.函数 2014-04-02 09:12:20|  分类: ORM框架|举报|字号 订阅          一.ef4.1 codeFirst 修改表结构 增加字段等 EF code ...

  8. TLF相关资料

    1\(转)http://blog.csdn.net/hu36978/article/details/5796165 TFL 一般先创建TextFlow  通过控制flowComposer属性来控制文本 ...

  9. java集合 collection-list-LinkedList

    import java.util.*; /* LinkedList:特有方法: addFirst(); addLast(); getFirst(); getLast(); 获取元素,但不删除元素.如果 ...

  10. QT 常用设置

    博文都写在了云笔记里面了,见谅,不想维护两个版本. QT 常用设置