A: 题意:给你一个半径为n的圆 求最少阻塞多少个点 才能使所以圆内及圆上的点 都不与外边的点相连  相连是距离为1 只算整数点

这题定住x,y依次递减 判断一下是否4-connect 这个意思就是 它上下左右有没有跟它相连的 圆是对称的 判断1/4圆就可以了

像左边的部分图 令初始y为n 只需要判断它的左上有没有跟它连接的就可以了  如果左边有的 话 y就减一  因为说明(i+1,y)已经不在圆内了 ,这里枚举的是圆内的点有没有跟圆外的点相连接

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
#define LL long long
int main()
{
LL n,i,j;
while(cin>>n)
{
LL s=;
if(n==)
{
puts("");
continue;
}
j = n;
for(i = ; i < n ;i++)
{
while((i+)*(i+)+j*j>n*n)
{
j--;
s++;
}
if((j+)*(j+)+i*i>n*n) s++;
}
cout<<s*<<endl;
}
return ;
}

B:题意:类似于汉诺塔 只不过加了每次挪动所需要的费用

可以递推出来 dp[i][j][g] = min(dp[i-1][j][v]+p[j][g]+dp[i-1][v][g],dp[i-1][j][g]*2+p[j][v]+dp[i-1][g][j]+p[v][g]) dp[i][j][g]表示把i个盘子从j移到G

这一长串的公式就是汉诺塔的移法 只不过不是最少的步骤了 一种是把i-1个盘子从1移到2,把第i个盘子从1移到3,把i-1个盘子再从2移到3,Ok.

第二种是 把第i-1个盘子从1移到3,把第i个盘子从1移到2,再把i-1个盘子从3移到1,再把第i个盘子从2移到3,最后把i-1个盘子从1移到3.

这两种方法取一个最优的。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
#include<vector>
using namespace std;
#define LL long long
#define INF 1e17
LL dp[][][];
int a[][];
int main()
{
int i,j,n,g;
for(i = ; i <= ; i++)
for(j = ; j <= ; j++)
cin>>a[i][j];
cin>>n;
for(i = ; i <= n ;i++)
for(j = ; j <= ; j++)
for(g = ; g <= ; g++)
if(i==) dp[i][j][g] = ;
else
dp[i][j][g] = INF;
int v;
for(i = ; i <= n ; i++)
{
for(j = ; j <= ; j++)
for(g = ; g <= ; g++)
{
if(j==g) continue;
for(int e = ; e <= ; e++)
if(e!=j&&e!=g) {v = e;break;}
dp[i][j][g] = min(dp[i-][j][v]+a[j][g]+dp[i-][v][g],*dp[i-][j][g]+a[j][v]+dp[i-][g][j]+a[v][g]);
}
}
cout<<dp[n][][]<<endl;
return ;
}

Codeforces Round #230 (Div. 1)的更多相关文章

  1. Codeforces Round #230 (Div. 2) 解题报告

    Problem A. Nineteen 思路: 除了首位像连的n,其他的字母不能共用nineteenineteen.所以可以扫描一遍所有的字符串将出现次数保存到hash数组,n的次数(n - 1) / ...

  2. Codeforces Round #230 (Div. 2) C Blocked Points

    题目链接 题意 : 给你一个半径为n的圆,圆里边还有圆上都有很多整点,让你找出与圆外的任意一个整点距离等于1的点. 思路 :这个题可以用枚举,画个图就发现了,比如说先数第一象限的,往下往右找,还可以找 ...

  3. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  4. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  5. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  6. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  7. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  8. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  9. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

随机推荐

  1. ASP.net MVC+ViewData VS ViewBag

         在使用MVC框架的过程中,往界面传值,我们使用的ViewData.如ITOO部分代码图解:      当然除了ViewData,我们还能够使用同卵兄弟(ViewBag)来完毕相同的功能,详情 ...

  2. Leetcode Single Number II (面试题推荐)

    还记得<剑指offer>和<编程之美>等书上多次出现的找一个数组中仅仅出现一次的数那个题吗? leetcode也有这道题 链接here  相信大家都知道用异或在O(n)的时间复 ...

  3. iOS开发--常用技巧 (MJRefresh详解)

         iOS开发--常用技巧 (MJRefresh详解) https://github.com/CoderMJLee/MJRefresh 下拉刷新01-默认 self.tableView.head ...

  4. Servlet访问Javabean并传结果给jsp

    1.先建立包名: 2.建立实体类 参考二维表,考虑各个字段名字.类型 在entity包里面建立一个类,代码如下: public class House { private String id; pri ...

  5. bzoj1486【HNOI2009】最小圈

    1486: [HNOI2009]最小圈 Time Limit: 10 Sec  Memory Limit: 64 MB Submit: 1778  Solved: 827 [Submit][Statu ...

  6. 深入理解Java执行时数据区

    前情回想 在本专栏的前12篇博客中. 我们主要大致介绍了什么是JVM, 而且具体介绍了class文件的格式. 对于深入理解Java, 或者深入理解运行于JVM上的其它语言, 深入理解class文件格式 ...

  7. CSS 对齐方式

    居中设置 Center Align - Using margin Setting the width of a block-level element will prevent it from str ...

  8. VisualSVN Server的配置和使用

    VisualSVN Server的配置与使用 本版本为VisualSVN Server 2.7.3版本-不同的版本可能在设置有不同的差异,但都大同小异 1.1启动界面 安装好 VisualSVN Se ...

  9. YTU 2428: C语言习题 计算该日在本年中是第几天

    2428: C语言习题 计算该日在本年中是第几天 时间限制: 1 Sec  内存限制: 128 MB 提交: 1505  解决: 857 题目描述 定义一个结构体变量(包括年.月.日).编写一个函数d ...

  10. YTU 1074: You are my brother

    1074: You are my brother 时间限制: 1 Sec  内存限制: 128 MB 提交: 10  解决: 7 题目描述 Little A gets to know a new fr ...