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. Tomcat启动报错 Failed to start component [StandardServer[8005]]解决

    SEVERE: The required Server component failed to start so Tomcat is unable to start. org.apache.catal ...

  2. 深入理解计算机系统第二版习题解答CSAPP 2.14

    假设x和y的字节值分别为0x66和0x39.填写下表,指明各个C表达式的字节值. 0x66 = 0110 0110(B) 0x39 = 0011 1001(B) 表达式 值 x & y 0x2 ...

  3. We~ˇsay~~ˇ

    拂弹每一个音符 与心相印 行走每一段风景 和路缠绵 花开的声音 只能用心倾听 无论曾经如何艰难 我依然在最初的起点 默念歌唱 等你 携手

  4. Android——将图片加入到系统相册里面

    Adnroid中保存图片的方法可能有如下两种: 第一种是自己写方法,如下代码: public static File saveImage(Bitmap bmp) { File appDir = new ...

  5. TCP/IP协议三次握手与四次握手流程解析(转载及总结)

    原文地址:http://www.2cto.com/net/201310/251896.html,转载请注明出处: TCP/IP协议三次握手与四次握手流程解析 一.TCP报文格式  TCP/IP协议的详 ...

  6. WebService简单介绍

    什么是Web Services 一直没有一个明确的答案,最近听了一个大牛讲WebService,顿时明了了,作个记录免得以后忘了. N年之前,各公司都在炒作SOA,不过现在已经没人再提了,现在都改叫W ...

  7. 关于Encoding.GetEncoding("utf-8")和Encoding.GetEncoding("GB2312")及Encoding.Default

    关于Encoding.GetEncoding("utf-8")和Encoding.GetEncoding("GB2312")及Encoding.Default ...

  8. Java实战之02Hibernate-03Session中的常用方法

    九.Session中的常用方法 1.save方法 都是临时态————>持久态 2.persist方法 作用: 持久化临时态对象. 与save方法的区别: 开始了事务:persist和save没有 ...

  9. 10_HTTP协议_入门知识

    [什么是HTTP协议] 对 浏览器客户端 和  服务器端之间的数据传输的格式规范. 客户端连上web服务器后,若想获得web服务器中的某个web资源,需遵循一定的通讯格式,HTTP协议用于定义客户端与 ...

  10. Java大数操作类

    Java的大数操作分为BigInteger和BigDecimal,但这两给类是分开使用的,有时候在编程的时候显得略微繁琐,现在编写了一个将二者合二为一的大数操作类. 大数操作类代码如下: packag ...