Codeforces Round #230 (Div. 1)
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)的更多相关文章
- Codeforces Round #230 (Div. 2) 解题报告
Problem A. Nineteen 思路: 除了首位像连的n,其他的字母不能共用nineteenineteen.所以可以扫描一遍所有的字符串将出现次数保存到hash数组,n的次数(n - 1) / ...
- Codeforces Round #230 (Div. 2) C Blocked Points
题目链接 题意 : 给你一个半径为n的圆,圆里边还有圆上都有很多整点,让你找出与圆外的任意一个整点距离等于1的点. 思路 :这个题可以用枚举,画个图就发现了,比如说先数第一象限的,往下往右找,还可以找 ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
- 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 ...
随机推荐
- react-redux 之 provider 和 connect
1.Provider 提供的是一个顶层容器的作用,实现store的上下文传递 2.connect 可以把state和dispatch绑定到react组件,使得组件可以访问到redux的数据 react ...
- Hive中行列转换
1.演示多列转为单行 数据文件及内容: student.txt xiaoming|english|92.0 xiaoming|chinese|98.0 xiaoming|math|89.5 huahu ...
- 最简单实用的MongoDB安装教程:在CentOS中使用 yum 安装MongoDB及服务器端配置详解
一.准备工作: 运行yum命令查看MongoDB的包信息 [root@vm ~]# yum info mongo-10gen (提示没有相关匹配的信息,) 说明你的centos系统中的yum源不包含M ...
- uva live 4394 String painter 区间dp
// uva live 4394 String painter // // 这一题是训练指南上dp专题的习题,初看之下认为仅仅是稍微复杂了一点 // 就敲阿敲阿敲,两个半小时后,发现例子过了.然而自己 ...
- cocos2d-x调用scheduleUpdate()不执行update()方法的解决办法【转】
原文地址:http://blog.csdn.net/somestill/article/details/9699377 前两天使用到每帧都更新动画的scheduleUpdate()方法,但通过cclo ...
- [学习笔记]渗透测试metasploit
1.渗透成功后,在meterpreter命令行,需要使用如下命令切换当前目录.更多信息,可以参考: meterpreter > pwd C:\ meterpreter > cd /&quo ...
- 关于maven pom
1 maven pom.xml只是配置文件 构建的流程已经固化在maven中了,pom.xml只是对这个流程的配置.特别是插件,在不进行人工绑定的情况下,插件是对应固定的生命周期的,我们操作的时候是操 ...
- css3动画应用-音乐唱片旋转播放特效
css3动画应用-音乐唱片旋转播放特效 核心点: 1.设置图片为圆形居中,使图片一直不停旋转. 2.文字标题(潘玮柏--反转地球)一直从左到右不停循环移动. 3.点击图标,音乐暂停,图片停止旋转:点击 ...
- ABAP 创建和调用WebService
1.创建WebService ① SE37创建RFC函数 ② SE80创建企业服务-service provider-existing ABAP object 或SE37-实用程序-创建Web服务 ③ ...
- (14)javaWeb中的HttpServletResponse类详解
如果希望了解请求和响应的详细内容,可以看我的“HTTP协议”系列文章 响应体的简单概述: a,响应报文结构: b,常见的状态码,返回服务器处理的结果: c,常见的响应头: HttpServletRes ...