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. 3D Touch的简单使用

    6s发布以后新增了一个3D touch功能,我个人觉得这个功能点在某些时候还是挺方便的,比如说微信的扫码功能. 直接长按图标就可以进入这个功能里面,不用再打开app.一层层查找了,比较方便. 其实这个 ...

  2. java基础学习总结六(对象与类、类的属性与方法)

    一:面向过程与面向对象的区别 举例:一个人开门的动作,可以分解为开门,人进去,关门. 面向过程:人作为执行者,1:开门  2:进入   3:关门 面向对象:人作为指挥者,将开门,关门的动作都封装到门上 ...

  3. Pyhont 网络编程【第一篇】初始Socket网络套接字

    一.什么是socket: Socket 别名 “网络套接字”,指网络通信链句柄 其实就是一堆网络信息(ip+端口) 建立起的链接称之为socket,Socket的英文原义是“孔”或“插座”,用来实现不 ...

  4. Xilinx 网站资源导

    Xilinx 网站资源导读 ———版权声明———–本文作者 Ricky Suwww.fpganotes.comrickysu.fpga@gmail.com 欢迎转载,转载请保持原样及署名商业使用须得到 ...

  5. asp中的几个取整函数fix(),int(),round()的用法

    asp中的几个取整函数是:fix(),int(),round(); Int(number).Fix(number)函数返回数字的整数部分.number 参数可以是任意有效的数值表达式.如果 numbe ...

  6. vs2010打开vs2012的sln文件

    1.找到**.sln文件,然后选择用记事本打开. 2.最前面找到“Microsoft Visual Studio Solution File, Format Version 12.00  # Visu ...

  7. JavaScript生成GUID的多种算法小结

    全局唯一标识符(GUID,Globally Unique Identifier)也称作 UUID(Universally Unique IDentifier) . GUID是一种由算法生成的二进制长度 ...

  8. ios开发之UIView的frame、bounds跟center属性的区别(附图)

    博文暂时想到什么写什么,不顺理成章,不顺章成篇. 先看几个概念 坐标点Poit:向右侧为X轴正方向的值x,原点下侧为Y轴正方向的值y 大小Size:由宽度width和高度height构成,表示一个矩形 ...

  9. 解决:The Operation couldn't be completed.(LaunchServicesError error 0.)

    问题描述:当运行Xcode6时,编译代码成功,但是登陆模拟器失败,显示错误: The Operation couldn't be completed.(LaunchServicesError erro ...

  10. JavaScript解析json

    后台数据经常以json数据格式传回前台,解析当然首选JSON对象. JSON对象有两个方法,使用JSON.parse(str)可以将json字符串解析成js中的对象. var o = JSON.par ...