A. Strange Addition time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digi…
1815: easy problem Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 98  Solved: 48 SubmitStatusWeb Board Description 给你一个数字N,N的范围是1~1000000,求一个最小的正整数M,这个数字M的各个位的数字加上它本身之和恰好为N.当然,如果没有解,输出0. Input 输入数据由多组数据组成,每行由一个数字N组成(1<=N<=1000000). Output 对于每组数据,输出…
C. Amr and Chemistry Problem's Link: http://codeforces.com/problemset/problem/558/C Mean: 给出n个数,让你通过下面两种操作,把它们转换为同一个数.求最少的操作数. 1.ai = ai*2 2.ai = ai/2 (向下取整) analyse: 基本思路:首先枚举出每个数能够到达的数字并且记录下到达该数组需要的步数,然后从到达次数为n次的数字中选择步数最小的即为答案. 对于一个数字Ai,它可以变换得到的数字可…
C. Amr and Chemistry Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/558/problem/C Description Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n different type…
点击打开链接 Amr and Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n di…
链接:http://codeforces.com/problemset/problem/558/C C. Amr and Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Chemistry, and specially doing experiments. He is preparing…
C. Amr and Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n differ…
C. Amr and Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n differ…
Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n different types of chemicals. Each chemical i has an initial volume of ai liters. For this experiment, Amr has to mix all the chemicals…
题目链接: C. Amr and Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n …
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n different types of chemicals. E…
题目链接:http://codeforces.com/problemset/problem/558/C 题意:有n个数,每个数都可以进行两个操作 *2 或者 /2,求最小的操作次数和,使得所有的数都相等: 计算一下时间复杂度可以知道每个数所能达到数的时间复杂度是log(1e5)最终的时间复杂度也就是 nlog(1e5), 所以暴力能过, 刚开始看到的时候一看数据范围就根本不敢暴力了... 我们可以把每个数所有变化情况都记录下来,并记录出现的次数,因为只有用1e5的数据量. 先把数据量范围内的所有…
题意:给出4个数字a,b,c,d,求出满足算式a*x1^2+b*x2^2+c*x3^2+d*x4^2=0的 (x1,x2,x3,x4) 的组合数.x的范围[-100,100],四个数字的范围 [-50,50] ,不能为0. 思路:对于每套给出的a,b,c,d四个数字,如果纯暴力的话要穷举100*100*100*100,每个例子要算1亿次,必须超时.可以算式左边两个部分右移,变成a*x1^2+b*x2^2  = -(c*x3^2+d*x4^2),那么只需要计算出左边的所有可能的结果,判断右边是否能…
大神 犯错合集及需要注意的东西 1.在一个地图求最大面积的类问题中,要注意障碍结点的影响. 2.ll(),表示的是在运算后把括号内强制转化为类型ll,而(ll)表示后面的每个玩意都强制转化为类型ll.在做历史研究这道题时我WA就是因为我用的是ll()而不是(ll). 3.splay每次splay操作后一定要记得更新root! 4.可以使用树状数组就尽量不要使用线段树.在Gty的文艺妹子序列这道题本机测试极限数据,线段树15s而树状数组4s,差距真大. 5.不需要开long long的就不要开lo…
 题意:给定一个数列,每次操作仅仅能将某个数乘以2或者除以2(向下取整). 求最小的操作次数使得全部的数都变为同样值. 比赛的时候最后没实现.唉.之后才A掉.開始一直在想二分次数,可是半天想不出怎么推断.后来发现事实上每一个数都能变成的数非常少非常少(最多400个不到).于是想到用数学方法+一点暴力,可惜时间不够了. 也不能全然算是数论题.仅仅是用到了一些数学思想.须要一点预处理,后面的计算中还会用到二分的技巧. 对某个数n,设n = s*2^r(当中s为奇数),则n能变成这样一些数:s*2…
暴力 #include<iostream> #include<string.h> #include<cstdio> using namespace std; int main() { int t=0,i=0; char s[10][12]; bool a[12][12]; memset(s,'\0',sizeof(s)); while(scanf("%s",s[i])!=EOF) { if(s[i][0]=='9') { t++; int state…
http://codeforces.com/problemset/problem/558/C 分析:将每一个数在给定范围内(10^5)可变成的数(*2或者/2)都按照广搜的方式生成访问一遍,标记上访问的步数,之后遍历区间找到被访问次数达到n(所有数都可以变成这个数)并且标记的需要步数最少即可. 注意:当是奇数的时候,例如11(11/2=5 5*2=10),按照这么算(除2后再乘2)回重新得到一个新的数 #include <cstdio> #include <cstring> #in…
题目链接:http://codeforces.com/problemset/problem/558/C 题意:把n个数变成相同所需要走的最小的步数易得到结论,两个奇数不同,一直×2不可能有重叠枚举每个数可能到得所有值,以及统计达到该值的时候已经走的步数最终答案就是1到up中num[i]最小的数 Examples input output 2 input output 5 Note In the first sample test, the optimal solution . In the se…
Codeforces 558C 题意:给n个数字,对每一个数字能够进行两种操作:num*2与num/2(向下取整),求:让n个数相等最少须要操作多少次. 分析: 计算每一个数的二进制公共前缀. 枚举法亦可. /* *Author : Flint_x *Created Time : 2015-07-22 12:33:11 *File name : whust2_L.cpp */ #include<iostream> #include<sstream> #include<fstr…
题意: n个数.每次能够选一个数 让其 *=2 或者 /=2 问至少操作多少次使得全部数相等. 思路: 对于每一个数,计算出这个数能够变成哪些数,以及变成那个数的最小步数,用两个数组保存 cnt[i] 表示序列中有cnt个数能够变成i step[i] 表示能变成i的 那些数 变成i的花费和是多少. 当中.遇到奇数的时候要特殊处理一下: 比方,7 能够通过 /2 然后 *2得到6,也就是说不论什么奇数 i (不包含1)都能够通过2次操作变为 i -1: 代码例如以下: #include<cstdi…
http://codeforces.com/contest/776/problem/C 一开始做的时候,就发现是预处理前缀和,然后对于每一个前缀和,如果他能成为一个贡献,就是能和前面的某些段 组合成和为k^x的话,那么需要cur_per_sum - val = k^x,这样可以解出val是多少,去前面找有多少个数是val就行了. 然后开始的时候我是先把所有数字都预处理然后放入map的,这样的做法是不对的,变得十分麻烦, 可能前面的前缀和是0,然后后面的前缀和也是0,但是当前枚举的这一位不能和后面…
C. Amr and Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n differ…
odds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 250    Accepted Submission(s): 72 Problem Description 度度熊有一棵 N 个节点 (node) 的有根树 (rooted tree),树上的每条边 (edge) 都有一个整数的权重,对于每一个非叶的节点 (non-leaf n…
C. Amr and Chemistry time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n differ…
好吧,再一次被水题虐了. A. Lala Land and Apple Trees 敲码小技巧:故意添加两个苹果树(-1000000000, 0)和(1000000000, 0)(前者是位置,后者是价值). B. Amr and The Large Array 找出最长的是哪些数字,然后再对这些数字找最大区间. 我居然还想用两个指针加有限队列维护!TAT C. Amr and Chemistry 首先,我们可以计算由x变为y的代价.O(1) 于是我枚举了\(a_0\)可以变为哪些数(最多\(m^…
CTSC Day -1 因为越发感到自己与dalao们之间姿势水平的差距,本来打算再多学些姿势,但被老师叫去做noi,于是花了一两周的时间做完了noi2011~2015,也学到了一些奇怪姿势,还是挺有收获的. CTSC Day 0 飞到北京,第一次来北京,但也没有什么特别的感觉,只觉得市里的建筑整洁度和规划啥的比福州强挺多的(福州某些地方破破烂烂的),但空气质量和福州真的没的比啊. 食堂菜还行,但感觉没冬令营时候的好,甚至感觉我校食堂会更好吃一点.后来某次和FallDream一起点了砂锅粉,味道…
bzoj2616 放一个车的时候相当于剪掉棋盘的一行,于是就可以转移了,中间状态转移dp套dp,推一下即可 bzoj2878 环套树期望dp 手推一下递推式即可 bzoj3295 树状数组套权值线段树 NOI2002贪吃的九头龙 多叉转二叉 水过 bzoj1495 方程就是f[i,j,k]表示以i为根,叶节点有j个A,所有的父节点状态为k的最佳值,然后方程就出来了f[i,j,k] = min(Σf[son,j1,k1]),其中Σj1=j,k1为k加上i的状态.然后把后两维用一个数压一下保存就好了…
学习:http://codeforces.com/blog/entry/44351 E. Lomsat gelral 题意: 给定一个以1为根节点的树,每个节点都有一个颜色,问每个节点的子树中,颜色最多的是哪几种颜色,输出这些颜色的值得和. 思路: 树上启发式合并的模板题,具体来说,先对树进行树链剖分,分出一个重链和轻边,dfs时,把每条轻儿子暴力加到根节点中,每次加的时候,用这样的技巧 if(csz < cnt[col[v]]) sum = col[v] , csz = cnt[col[v]]…
做题 对于习题方面,我们感觉一个暑假还是留下了不少的题要写,大部分应该是讲师讲课的例题,还有少部分考试题.考试题没有订正完是因为还有算法不会,或是因为题太毒瘤了不会.同时,也发现自己还是有很多应该学的算法没学过也没写过,习题和算法就尽量留在假期补吧. 其实在学校的时候感觉做题效率还不错,每天基本更够做完\(60\%\)以上的题,只要多抓紧时间还是能写不少题的,就是感觉机房水分比较足,有点受周围人影响. 考试 一开始几天还有最后几天其实考得都还行,就是中间有几天考的不好.可能是因为犯了不该犯的低级…
Problem B. 即时战略 (rts.c/cpp/pas) 注意 Input file: rts.in Output file: rts.out Time Limit : 2 seconds Memory Limit: 512 megabytes 题面 \(\text{HLY}\)在玩一个即时战略\(\text{(Real Time Strategy)}\)游戏.与大多数同类游戏类似,这个游戏的地图是平面的,并且玩家都有一个基地. \(\text{HLY}\)的对手杰哥的基地是一个\(w \…