UVA10079 Pizza Cutting 题解】的更多相关文章

Content 求用 \(n\) 条直线最多能将平面分成多少块区域. 多组输入,以一个负数结束. 数据范围:\(0\leqslant n\leqslant 2.1\times 10^8\). Solution 小学奥数题. 首先你得要知道 \(1+2+...+n=\dfrac{n(n+1)}{2}\). 我们先通过画图来找一下规律. 不切,此时很显然总共有 \(1\) 个区域. 切一刀,此时最多有 \(2\) 个区域. 切两刀,此时最多有 \(4\) 个区域. 切三刀,此时最多只能有 \(7\)…
题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识:while not eof,分支语句,求余 PS:%表示求余 题号:a004: 文文的求婚 背景知识:while not eof,分支语句,判断闰年 题号:a005: Eva 的回家作業 背景知识:循环,if语句,等比数列,等差数列,输出语句 题号:a006: 一元二次方程式 背景知识:if语句的…
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes…
[题解]Cutting Game vjudge 谈谈对\(sg\)函数的理解? 浅谈公平组合游戏IGC //@winlere #include<cstring> #include<cstdio> using namespace std; typedef long long ll; const int maxn=201; int temp[maxn]; int sg[maxn][maxn],a,b; int main(){ for(register int n=2;n<=200…
题意:有1~n个小环,他们中的有些互相扣在一起,问你至少切开几个能把这写小环串成一条链 思路:还是太菜了,题目给的n<=15,显然可以暴力解决. 用二进制表示每个环切还是不切,然后搜索所有情况.当一种情况满足一下两点:1.切完之后每一串连在一起的环应该是一条链,没有分支没有环:2.当一个环被切开,那么他就可以当做任意串的连接点,那么显然切开的点+1>=串的数量. 代码: #include<set> #include<map> #include<stack>…
思路:dfs找先手必胜的情况是否存在 代码: #include<stack> #include<vector> #include<queue> #include<set> #include<cstring> #include<string> #include<sstream> #include<iostream> #include<cstdio> #include<cmath> #inc…
题意: 标记为\(1-n\)的竹子,\(q\)个询问,每次给出\(l,r,x,y\).要求为砍区间\(l,r\)的柱子,要求砍\(y\)次把所有竹子砍完,每次砍的时候选一个高度,把比他高的都砍下来,并且这\(y\)次砍下来长度都相等,问第\(x\)次砍在什么高度. 思路: 显然就是要求选一个高度砍,使得剩下的高度为\((sum[r] - sum[l - 1]) - (sum[r] - sum[l - 1])/y * x\),那么直接建好主席树,然后二分出这个高度. 主席树好啊. 代码: #inc…
题目描述 Michael请N个朋友吃馅饼,但是每个朋友吃且仅吃一个馅饼的1/4.1/2或3/4.请你编程求出Michael至少需要买多少个馅饼. 输入输出格式 输入格式: 输入文件的第一行是整数N:接下来的N行中,每行都是1/4.1/2或3/4. 输出格式: 输出文件仅有一行包含一个整数--至少需要购买的馅饼数目. 输入输出样例 输入样例#1: 复制 6 3/4 1/2 3/4 1/2 1/4 1/2 输出样例#1: 复制 4 说明 1 ≤ N ≤ 10,000 思路 简单贪心但要注意细节讨论…
Content 小 S 想把一块披萨切成大小.形状都相同的 \((n+1)\) 块(\(n\) 块分给 TA 的 \(n\) 个朋友,还有一块留给自己),试问最小需要切多少块. 数据范围:\(0\leqslant n\leqslant 10^{18}\). Solution 首先这道题目坑的一点就是 \(n\) 可能等于 \(0\),这时候不需要再切了,答案是 \(0\). 然后看 \(n\neq 0\) 的情况. 首先是 \(2\mid (n+1)\) 的情况,那么我们可以发现有两次可以当一次…
Cutting Game 题意: 有一张被分成 w*h 的格子的长方形纸张,两人轮流沿着格子的边界水平或垂直切割,将纸张分割成两部分.切割了n次之后就得到了n+1张纸,每次都可以选择切得的某一张纸再进行切割.最先切出只有一个格子的纸张(即有 1*1 格子的)的一方获胜.当双方都采取最优策略时,先手必胜还是必败? 题解: 这题是小白书上的,在取得游戏中必胜策略的最后一题,我照着码一遍就叫了,结果居然T了,,最后发现是cin的问题,然后关下同步就可以a了,但好险用了913ms... 还有初始化mem…
Tree Cutting Problem Description Byteasar has a tree T with n vertices conveniently labeled with 1,2,...,n. Each vertex of the tree has an integer value vi.The value of a non-empty tree T is equal to v1⊕v2⊕...⊕vn, where ⊕ denotes bitwise-xor.Now for…
3391: [Usaco2004 Dec]Tree Cutting网络破坏 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 47  Solved: 37[Submit][Status] Description     约翰意识到贝茜建设网络花费了他巨额的经费,就把她解雇了.贝茜很愤怒,打算狠狠报 复.她打算破坏刚建成的约翰的网络.    约翰的网络是树形的,连接着N(1≤N≤10000)个牛棚.她打算切断某一个牛棚的电源,使和这个牛棚相连的所有电缆全…
3391: [Usaco2004 Dec]Tree Cutting网络破坏 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 76  Solved: 59[Submit][Status][Discuss] Description     约翰意识到贝茜建设网络花费了他巨额的经费,就把她解雇了.贝茜很愤怒,打算狠狠报 复.她打算破坏刚建成的约翰的网络.    约翰的网络是树形的,连接着N(1≤N≤10000)个牛棚.她打算切断某一个牛棚的电源,使和这个牛…
Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on the crust, and he does not really like the crust. The pizza is a circle of radius r and center at the origin. Pizza consists of…
题目链接:Cutting Out 题意:给定一个n长度的数字序列s,要求得到一个k长度的数字序列t,每次从s序列中删掉完整的序列t,求出能删次数最多的那个数字序列t. 题解:数字序列s先转换成不重复的数字序列,并记录各个数字重复的次数,然后按照重复次数从大到小排序.二分最大删除次数,最后再输出对应的序列t. #include <map> #include <cstdio> #include <iostream> #include <algorithm> us…
容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001  A+B Problem First AC: 2017-10-13       Latest Modification: 2018-02-28 #include<bits/stdc++.h> using namespace std; int a,b; int main() { cin>>a>>b; cout<<…
这场有点难,QAQ.补了好久(。• ︿•̀。) ,总算能写题解了(つд⊂) A. Beautiful numbers CodeForces - 55D 题意 ​ 求\([l,r](1\le l_i\le r_i\le 9\cdot 10^{18})\)的中的 可以被自己每一位上的数字整除的数 的个数. 题解: ​ 知识:如果m%a=0,则任意x, x%a = (x%m)%a. ​ 2520是2~9的lcm.因此任何时候都有2520%pre_lcm==0. ​ 因为2520%pre_lcm==0,…
[HDU5909]Tree Cutting(FWT) 题面 vjudge 题目大意: 给你一棵\(n\)个节点的树,每个节点都有一个小于\(m\)的权值 定义一棵子树的权值为所有节点的异或和,问权值为\(0..m-1\)的所有子树的个数 题解 考虑\(dp\) 设\(f[i][j]\)表示以\(i\)为根节点的子树中,异或和为\(j\)的子树的个数 很显然,每次合并就是两个\(dp\)值做\(xor\)卷积 那么直接用\(FWT\)优化就行了 #include<iostream> #inclu…
Mr. Pippo's Pizza 题目连接: https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/mr-pippos-pizza Description Mr. Pippo wants to start a new pizza shop. Everything about his pizzas is unique - the recipe is unique, the taste is unique, and…
Tree Cutting 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5909 Description Byteasar has a tree T with n vertices conveniently labeled with 1,2,...,n. Each vertex of the tree has an integer value vi. The value of a non-empty tree T is equal to v1⊕v…
Cutting Tree 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4922 Description Tree in graph theory refers to any connected graph (of nodes and edges) which has no simple cycle, while…
A. Cutting Banner Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/problem/A Description A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Un…
Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选一些题来写吧. B. Tanya and Candies 题意: 在n个数中任意删去一个,如果这个数被删去后,剩余数的奇数和以及偶数和相等,那么就定义这个数为"好数".现在问这n个数中有多少个“好数”. 题解: 预处理出奇数前缀和.偶数前缀和,删去一个数后所有的奇数位置和 就为前面的奇数和…
题文: 见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=944(紫书p2001) 题解:区间dp,可以设dp[l][r]表示区间i到j的最小花费,所以 dp[l][r]=min(dp[l][r],DP(l,k)+DP(k,r)+cut[r]-cut[l]);k为一个断点,cut[r]-cut[l]为第一次切的花费,转移也非常显然,不过注…
A. Pizza Separation time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pi…
A过水,不讲 题解 CF1077B [Disturbed People] 这题就是个显而易见的贪心可是我考场上差点没想出来 显然把一户被打扰的人家的右边人家的灯关掉肯定比把左边的灯关掉 从左到右扫一遍,每次如果遇到一户被打扰的人家就ans++,然后把它右边的灯关掉 然后就做完了 # include <bits/stdc++.h> int a[101]; int main() { int n; int ans = 0; scanf("%d", &n); for(int…
打算写一个多项式总结. 虽然自己菜得太真实了. 好像四级标题太小了,下次写博客的时候再考虑一下. 模板 \(FFT\)模板 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cctype> #include <algorithm> #define rin(i,a,b)…
C - Ordering Pizza CodeForces - 867C C - Ordering Pizza 这个是最难的,一个贪心,很经典,但是我不会,早训结束看了题解才知道怎么贪心的. 这个是先假设每个人都可以吃到他喜欢的,就是先求出答案,然后按照b-a 排序,分别放入两个优先队列里面, 如果b>a 那就吃第二块,否则就吃第一块,求出num,注意优先队列按照从小到达排序. num1记录第一块吃的数量,num2记录第二块吃的数量. num1%=s,num2%=s  如果num1+num2的数…
原题如下: Cutting Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5721   Accepted: 2083 Description Urej loves to play various types of dull games. He usually asks other people to play with him. He says that playing those games can show…
AtCoder Beginner Contest 238 \(A - F\) 题解 A - Exponential or Quadratic 题意 判断 \(2^n > n^2\)是否成立? Solution 当 \(n\) 为 2,3,4 的时候不成立,否则成立 Code #include <bits/stdc++.h> using namespace std; using LL = long long; int main() { int n; cin >> n; bool…