CF846E - Chemistry in Berland】的更多相关文章

这题乍一看是一道水树形DP(其实事实上它确实是树形DP),然后设f[i]表示第i个点所多余/需要的材料,然后我们愉快的列出了式子: if(f[v]<0) f[u] += f[v] * edges[c_e].dis; else f[u] += f[v]; 然后放到CF上,直接WA,十分自闭,于是我试图define int long long,还是没过,仔细一想(偷瞄了一眼CF的数据),发现f数组有可能会爆long long,怎么办?高精? 显然这不太现实,于是想着如果它要爆了就把它置回边缘,实测不…
题目 题意: 有n种化学物质,第i种物质现有bi千克,需要ai千克.有n-1种,编号为2-n的转换方式,每种都为(x,k),第i行是编号为i+1的转换方式,编号为i的转换方式(xi,ki)表示ki千克的xi物质可以转换成1千克的i物质,1千克的i物质可以转换成1千克的xi物质.问是否可能通过转换得到足够的需要的物质.(1 ≤ xj + 1 ≤ j) 重点:上面标红的条件.如果只保留ki千克的xi物质可以转换成1千克的i物质产生的一条有向边,表明xi物质连出的边一定是指向编号大于i的物质的(x[i…
咸鱼选手发现自己很久不做cf了,晚节不保. A.Curriculum Vitae 枚举一下间断点的位置. #include<bits/stdc++.h> using namespace std; ; int cnt,n,a[N],mx,cur; inline int read(){ ,x=;char ch; ;}'); +ch-'); return f*x; } int main(){ n=read(); ;i<=n;i++)a[i]=read(); ; ;i<=n;i++){ c…
The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of water cells, connected by sides, which are not connect…
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or…
Description The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of water cells, connected by sides, which are…
题目链接: 传送门 Berland Bingo time limit per test:1 second     memory limit per test:256 megabytes Description Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with…
题目链接: 传送门 DZY Loves Chemistry time limit per test:1 second     memory limit per test:256 megabytes Description DZY loves chemistry, and he enjoys mixing chemicals. DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals…
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,它可以变换得到的数字可…
B. Berland National LibraryTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/B Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of…