E. Dasha and Puzzle 数学题】的更多相关文章

http://codeforces.com/contest/761/problem/E 给出一颗树,要求在坐标系中用平行于坐标轴的线描绘出来. 要求边不能相交,而且点的坐标唯一. 注意到2^1 + 2^2 + ..... + 2^n = 2^(n + 1) - 1 那就是说,如果第一条边的边长是2^(n + 1),那么后面的边选2^n . 2^(n -  1)等等,相加起来也不会越过第一条,所以也就不会相交. #include <cstdio> #include <cstdlib>…
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…
题目链接 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…
C. Rectangle Puzzle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/281/problem/C Description You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the cen…
http://codeforces.com/contest/761/problem/E 题意:给出一棵树,现在要把这棵树上的结点放置在笛卡尔坐标上,使得每一条边与x轴平行或者与y轴平行.输出可行解,即每个点放置的坐标. 思路: 一开始我想,这个每条边的边长都是可长可短的,好像很麻烦啊. 做法还是很巧妙的,因为最多也就30个点,所以我们直接让该点连接的边未len长度,然后dfs它的子节点并使它的子节点的边长为len/2.你会发现,这样线段就不会相交了. #include<iostream> #i…
[题目链接]: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个节点,所以这么做肯定是可以…
A. Dasha and Stairs Problems: 一个按照1,2,3……编号的楼梯,给定踩过的编号为奇数奇数和偶数的楼梯数量a和b,问是否可以有区间[l, r]符合奇数编号有a个,偶数编号有b个. Analysis: cj: 纸张的我=.= 经过Return改正,才发现没有主义a = b = 0的情况. #define PRON "a" #include <cstdio> #include <cstring> #include <vector&g…
A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On her way to programming school tiger Dasha faced her first test — a huge staircase! The steps were numbered from one t…