Codeforces 761E Dasha and Puzzle(构造)】的更多相关文章

题目链接 Dasha and Puzzle 对于无解的情况:若存在一个点入度大于4,那么直接判断无解. 从根结点出发(假设根结点的深度为0), 深度为0的节点到深度为1的节点的这些边长度为2^30, 深度为1的节点到深度为2的节点的这些边的长度为2^29, ……………………………………………………………… 以此类推. 因为结点个数最多只有30个,所以长度分配足够. #include <bits/stdc++.h> using namespace std; #define REP(i,n) fo…
E. Dasha and Puzzle 题目连接: http://codeforces.com/contest/761/problem/E Description Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity - origami, but remembered the puzzle that she could not solve…
E. Dasha and Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity — origami, bu…
E. Dasha and Puzzle time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity — origami, bu…
E. Dasha and Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity — origami, bu…
[题目链接]:http://codeforces.com/contest/761/problem/E [题意] 给你一棵树,让你在平面上选定n个坐标; 使得这棵树的连接关系以二维坐标的形式展现出来; [题解] dfs来搞; 显然如果某个点的度数大于4就无解. 初始坐标为(0,0)然后每一层的边的长度变为上一层长度的1/2 初始层的长度为2 30   这样可以保证每层节点都不会和上一层的相交; 因为2 i >2 1 +2 2 +...+2 i−1   又因为最多只有30个节点,所以这么做肯定是可以…
http://codeforces.com/contest/761/problem/E 题意:给出一棵树,现在要把这棵树上的结点放置在笛卡尔坐标上,使得每一条边与x轴平行或者与y轴平行.输出可行解,即每个点放置的坐标. 思路: 一开始我想,这个每条边的边长都是可长可短的,好像很麻烦啊. 做法还是很巧妙的,因为最多也就30个点,所以我们直接让该点连接的边未len长度,然后dfs它的子节点并使它的子节点的边长为len/2.你会发现,这样线段就不会相交了. #include<iostream> #i…
Tautonym Puzzle Time Limit: 50 Sec  Memory Limit: 256 MB Description 定义一个序列贡献为1,当且仅当这个序列 由两个相同的串拼接而成,比如123123. 请构造一个序列,使得它子序列的贡献和为n. 要求序列长度<=200,权值<=100. Input 一行一个n. Output 第一行为长度len,表示你构造出的序列长度. 第二行为你构造出的序列. Sample Input 7 Sample Output 4 1 1 1 1…
B. z-sort 题目连接: http://www.codeforces.com/contest/652/problem/B Description A student of z-school found a kind of sorting called z-sort. The array a with n elements are z-sorted if two conditions hold: ai ≥ ai - 1 for all even i, ai ≤ ai - 1 for all…
题目链接:http://codeforces.com/contest/707/problem/C 题目大意:给你一条边,问你能否构造一个包含这条边的直角三角形且该直角三角形三条边都为整数,能则输出另外两条边,否则输出-1“”. 解题思路:下面是我从作业帮上找的- -, 利用平方差公式令斜边为c,直角边为a.b,且b为最短边c²-a²=(c+a)(c-a)因此(c+a)(c-a)是完全平方数,且(c-a)是(c+a)的一个因数1.如果(c-a)=1,则(c+a)是完全平方数(最短边是任意大于2的奇…