codeforces 388B Fox and Minimal path
这个题目的突破口就是固定最短长度,然后以二进制的形式分层;
最后把需要的曾连起来;
#include<cstdio>
#include<cstring>
#define maxn 105
using namespace std; bool map[maxn][maxn]; void link(int x,int y)
{
map[x][y]=;
map[y][x]=;
} void pre()
{
link(,);
link(,);
link(,);
for(int i=; i<; i+=)
{
link(i,i+);
link(i,i+);
link(i+,i+);
link(i+,i+);
}
for(int i=; i<; i++)
link(i,i+);
} void solve(int k)
{
for(int i=; i<=; i++)
{
if(<<i&k)
{
link(*i+,+i);
link(*i+,+i);
}
}
if(k&)link(,);
printf("100\n");
for(int i=; i<=; i++)
{
for(int j=; j<=; j++)
{
if(map[i][j])
putchar('Y');
else putchar('N');
}
puts("");
}
} int main()
{
pre();
int k;
scanf("%d",&k);
solve(k);
return ;
}
codeforces 388B Fox and Minimal path的更多相关文章
- Codeforces Round #228 (Div. 1) 388B Fox and Minimal path
链接:http://codeforces.com/problemset/problem/388/B [题意] 给出一个整数K,构造出刚好含有K条从1到2的最短路的图. [分析] 由于是要自己构造图,当 ...
- Codeforces Round #228 (Div. 1) B. Fox and Minimal path 构造
B. Fox and Minimal path 题目连接: http://codeforces.com/contest/388/problem/B Description Fox Ciel wants ...
- codeforces 389 D. Fox and Minimal path(构造+思维)
题目链接:https://vjudge.net/contest/175446#problem/J 题解:显然要用最多n个点构成的图要使的得到的最短路条数有1e9次个,显然要有几个数相乘容易想到2的几进 ...
- CF #228 div1 B. Fox and Minimal path
题目链接:http://codeforces.com/problemset/problem/388/B 大意是用不超过1000个点构造一张边权为1的无向图,使得点1到点2的最短路的个数为给定值k,其中 ...
- Educational Codeforces Round 25 E. Minimal Labels&&hdu1258
这两道题都需要用到拓扑排序,所以先介绍一下什么叫做拓扑排序. 这里说一下我是怎么理解的,拓扑排序实在DAG中进行的,根据图中的有向边的方向决定大小关系,具体可以下面的题目中理解其含义 Educatio ...
- CodeForces 388A Fox and Box Accumulation (模拟)
A. Fox and Box Accumulation time limit per test:1 second memory limit per test:256 megabytes Fox Cie ...
- CodeForces - 512B Fox And Jumping[map优化dp]
B. Fox And Jumping time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces 388C Fox and Card Game (贪心博弈)
Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her fr ...
- codeforces 510B. Fox And Two Dots 解题报告
题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...
随机推荐
- 【Codeforces Round#279 Div.2】B. Queue
这题看别人的.就是那么诚实.http://www.cnblogs.com/zhyfzy/p/4117481.html B. Queue During the lunch break all n Ber ...
- 那些好用的iOS开发工具
版权说明 本文首发于<程序员>杂志 2014 年 6 月刊,未经允许,请勿转载. 前言 从 苹果发明 iPhone 起,AppStore 上的一个又一个类似 flappy bird 的一夜 ...
- nvl()函数
Oracle里面的nvl()函数 Nvl(字段名,0):如果你某个字段为空,但是你想让这个字段显示0,nvl(字段名,0) ,就是当你选择出来的时候,这个字段虽然为空,但是显示的是0,当然这个0也可以 ...
- 从NSM到Parquet:存储结构的衍化
http://blog.csdn.net/dc_726/article/details/41777661 为了优化MapReduce及MR之前的各种工具的性能,在Hadoop内建的数据存储格式外,又涌 ...
- 修改ckeditor/ckfinder上传文件文件夹 路径以日期格式命名
修改/ckfinder/config.ascx文件: string dateDir = DateTime.Today.ToString("yyyyMM/"); ResourceTy ...
- 使用netbeans 搭建 JSF+SPRING 框架
spring版本使用4,jsf版本2.2 jsf的配置文件faces-config.xml <?xml version='1.0' encoding='UTF-8'?> <faces ...
- 【JAVA】浅谈java枚举类
一.什么情况下使用枚举类? 有的时候一个类的对象是有限且固定的,这种情况下我们使用枚举类就比较方便? 二.为什么不用静态常量来替代枚举类呢? public static final int SEASO ...
- linux时间无法同步的解决方案
问题描述: 在家里的ubuntu和windows上始终无法同步时间,也参考了很多资料还是不行.无意中的一次把笔记本拿到公司,发现可以同步时间,但是就觉得奇怪了.对比之后才发现是移动的网络没法连接ntp ...
- ###《More Effective C++》- 异常
More Effective C++ #@author: gr #@date: 2015-05-24 #@email: forgerui@gmail.com 九.利用destructors避免泄漏资源 ...
- 通过google找网站后台的方法
转自:http://cyuyanbiancheng.blog.hexun.com/69239903_d.html site:url.com '查看这个站点上的信息最好不加www,可以查看到不少的二级域 ...