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 ...
随机推荐
- ASP.net MVC+ViewData VS ViewBag
在使用MVC框架的过程中,往界面传值,我们使用的ViewData.如ITOO部分代码图解: 当然除了ViewData,我们还能够使用同卵兄弟(ViewBag)来完毕相同的功能,详情 ...
- Web开发从零单排之一:在新浪云平台SAE上开发一个html5电子喜帖
需求描述: 本人大婚将至,女朋友说“现在都流行在微信上发电子请帖了,你不是技(cheng)术(xu)宅(yuan)嘛,不会连这个都搞不定吧” 本人嘴上说这等小事何足挂齿,但心里还是七上八下的,虽然自认 ...
- python实现接口自动化
一.总述 Postman:功能强大,界面好看响应格式自主选择,缺点支持的协议单一且不能数据分离,比较麻烦的还有不是所有的公司都能上谷歌SoupUI:支持多协议(http\soup\rest等),能实现 ...
- Mongodb for PHP教程之入门安装
简介: MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似json的bjson格式,因此可以存储比较复杂的数据 ...
- Idea SpringMVC+Spring+MyBatis+Maven整合
创建项目 File-New Project 选中左侧的Maven,选中右侧上方的Create from archetype,然后选中下方列表中的webapp,然后点击Next 在GroupId和Art ...
- leetcode:283. Move Zeroes(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址:http://blog.csdn.net/u012975705/article/details/50493772 题目地址:https://leet ...
- struts2 java.io.FileNotFoundException: http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd
xxx-validation.xml 文件里 java.io.FileNotFoundException: http://www.opensymphony.com/xwork/xwork-valid ...
- Unable to find a team with the given Team ID或者Failed to code sign的问题解决
Unable to find a team with the given Team ID或者Failed to code sign的问题解决 1:问题描述(注:这种情况一般是下载并打开别人项目时) F ...
- Django 使用UEditor
Django package 的一些包不支持upload file, 而且 有几个支持的不是收费的就是要开csrf ,这对于苦逼程序猿来说始终是件恼火的事.所以经过查阅各种资料.看了各种各样的配置do ...
- 自己动手写最简单的Android驱动---LED驱动的编写【转】
本文转载自:http://blog.csdn.net/k_linux_man/article/details/7023824 转载注明出处,作者:K_Linux_Man, 薛凯 山东中医药大学,给文章 ...