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. SqlServer 经常使用分页方法总结

    SqlServer 经常使用分页方法总结 以下演示样例总结了,SqlServer数据库 经常使用分页方法,仅供学习參考 A. 使用 RowNumber 和 Between And 组合分页: /*** ...

  2. Mongodb for PHP教程之数据操作

    Mongodb的常用操作 参看手册,php官方的http://us2.php.net/manual/en/mongo.manual.php 也可以参看mongodb官方的教程 数据库连接 ⑴默认格式 ...

  3. 广东IP段列表

    广东IP段列表219.137.240.0 219.137.240.255219.137.148.0 219.137.150.255 广东省广州市 电信ADSL219.137.144.0 219.137 ...

  4. ym——优化你的Java代码(新)

    转载请注明本文出自Cym的博客(http://blog.csdn.net/cym492224103),谢谢支持! 1.面向对象的3要素. 2.面向对象开发的6大原则. 1.单一职责原则 应该有且仅有一 ...

  5. 硬件开发之bt输出---BT656/BT601/BT1120协议以及DM365/DM355/DM6467上使用的YUV颜色空间说明

    http://blog.csdn.net/zhouzhuan2008/article/details/17168133

  6. ArrayAdapter requires the resource ID to be a TextView

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABDUAAADFCAIAAADLz168AAAgAElEQVR4nO2d368kxZXnQ37dn9qdWa

  7. mysql13---索引使用注意

    .4唯一索引 ①当表的某列被指定为unique约束时,这列就是一个唯一索引 ) unique); 这时, name 列就是一个唯一索引. unique字段可以为NULL,并可以有多NULL(,null ...

  8. YTU 1001: A+B Problem

    1001: A+B Problem 时间限制: 1 Sec  内存限制: 10 MB 提交: 4864  解决: 3132 [提交][状态][讨论版] 题目描述 Calculate a+b 输入 Tw ...

  9. 一步一步学Silverlight 2系列(5):实现简单的拖放功能

    述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...

  10. EF1:MVC/EF(Entity Framewok) /First Migrations

    1. 概念 Entity Framework: ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R Mapping) 解决方案.(此处 ...