Codeforces 449 B. Jzzhu and Cities】的更多相关文章

堆优化dijkstra,假设哪条铁路能够被更新,就把相应铁路删除. B. Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities numbered from 1 to n in his co…
D. Jzzhu and Cities time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Jzzhu is the president of country A. There are \(n\) cities numbered from \(1\) to \(n\) in his country. City \(1\)…
C. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to…
题目描述: Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of…
D. Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A.…
CF449B CF450D http://codeforces.com/contest/450/problem/D http://codeforces.com/contest/449/problem/B Codeforces Round #257 (Div. 2) D Codeforces Round #257 (Div. 1) B D. Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megaby…
CF449B Jzzhu and Cities 其实这一道题并不是很难,只是一个最短路而已,请继续看我的题解吧~(^▽^) AC代码: #include<bits/stdc++.h> #define maxn 3000005 #define pa pair<long long,long long> #define inf 1000000000000000000ll using namespace std; long long n,m,k; struct edge{ long lon…
[题目链接] https://codeforces.com/contest/449/problem/B [算法] 最短路 时间复杂度 : O(N ^ 2) [代码] #include<bits/stdc++.h> using namespace std; ; const int INF = 2e9; int n , m , k; int mark[MAXN]; long long dist[MAXN]; bool inq[MAXN]; vector< pair<int,int>…
输入一个无向图<V,E>    V<=1e5, E<=3e5 现在另外给k条边(u=1,v=s[k],w=y[k]) 问在不影响从结点1出发到所有结点的最短路的前提下,最多可以删除k条边的多少条 跑最短路的时候维护或者统计就好了 一开始用spfa.然后TLE 45...好久没写  Dij+堆优化   ... p.s.优先队列默认大顶堆 Dij+堆优化   264ms #include <cstdio> #include <cstring> #include…
题意:n个城市,中间有m条道路(双向),再给出k条铁路,铁路直接从点1到点v,现在要拆掉一些铁路,在保证不影响每个点的最短距离(距离1)不变的情况下,问最多能删除多少条铁路 分析:先求一次最短路,铁路的权值大于该点最短距离的显然可以删去,否则将该条边加入图中,再求最短路,记录每个点的前一个点,然后又枚举铁路,已经删去的就不用处理了,如果铁路权值大于该点最短距离又可以删去,权值相等时,该点的前一个点如果不为1,则这个点可以由其他路到达,这条铁路又可以删去. 由于本题中边比较多,最多可以有8x10^…
#include<bits/stdc++.h> #define MAXN 100050 #define MAXM 900000 using namespace std; struct st { int id; long long dis; st(int a,long long b) { id=a; dis=b; } st(){}; }; struct edge{ bool im; int id; long long w; edge *next; }; edge *adj[MAXN]; edge…
Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of t…
题目链接:http://codeforces.com/contest/450/problem/B 解题报告:f1 = x,f2 = y,另外有当(i >= 2) fi = fi+1 + fi-1,现在给出x和y,k,让你输出fn % (1e9+7) 对于这题我真想说细节决定一切,f的值一共只有6个,只要把f的值全部打表打出来了就可以直接得出任何一个fk的值. 但是注意x和y的范围都是小于10^9,所以当(x+y) % MOD的时候就会可能出现还是负数的情况,所以说交题之前最好测下极端的情况,因为…
CF #257 div2D:http://codeforces.com/contest/450/problem/D 题意:给你n个城市,m条无向有权边.另外还有k条边,每条边从起到到i.求可以删除这k条边中的多少条,使得每个点到1的最短距离不变. 题解:通过这一题明白了,对于一个问题要有分析思考的能力.首先分析一下,对于城市i,(1)如果没有从1到i的特殊边(即上述k条中的一条),我们不用考虑.(2)如果有,在这之前已经求出了每个点的最短路,如果这条边的边权大于等于最短路,则可以直接删除,一不会…
#449 Div2 D 题意 交互式类题目. 起始有 n 张纸,会给出 m 次数字 p (\(1 \leq p \leq c\)),每次可选择一张纸,并在纸上写上这个数字,如果纸上已经存在数字,会覆盖掉原来的数字.问不超过 m 次能否使得所有纸上都有数字且不降序排列. 分析 这类想法题挺常见的了,观察数据范围 $ \left \lceil \frac{c}{2} \right \rceil \cdot n \leq m$,我们可以这么理解, \(n\) 张纸,每张最多变 $ \left \lce…
题目链接: A. Buses Between Cities time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at…
题目链接: B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculat…
C. Jzzhu and Chocolate time limit per test: 1 seconds memory limit per test: 256 megabytes input: standard input output: standard output Jzzhu has a big rectangular chocolate bar that consists of \(n × m\) unit squares. He wants to cut this bar exact…
E. Jzzhu and Apples time limit per test: 1 seconds memory limit per test: 256 megabytes input: standard input output: standard output Jzzhu has picked \(n\) apples from his big apple tree. All the apples are numbered from \(1\) to \(n\). Now he wants…
CF挂0了,简直碉堡了.两道题都是正确的思路但是写残了.写个解题报告记录一下心路历程. A题问的是 一个n*m的方块的矩形上切k刀,最小的那一块最大可以是多少.不难发现如果纵向切k1刀,横向切k2刀,那么答案应该是 (n/(k1+1)) * (m/(k2+1)),除法是取整的.虽然是取整,但是不难发现其实就是要(k1+1)*(k2+1)最小,根据均值不等式,k1+k2=k(定值) k1==k2的时候(k1+1)*(k2+1)=k1*k2+k1+k2+1=k1*k2+k+1应该是取最大值,所以当k…
题意:给出f1=x,f2=y,f(i)=f(i-1)+f(i+1),求f(n)模上10e9+7 因为 可以求出通项公式:f(i)=f(i-1)-f(i-2) 然后 f1=x; f2=y; f3=y-x; f4=-x; f5=-y; f6=-y+x; f7=x; 发现是以6为循环的 还有注意下余数为正,就每次加上一个mod再模上mod #include<iostream> #include<cstdio> #include<cstring> #include <cm…
//area=(n*m)/ ((x+1)*(k-x+1)) //1: x==0; //2: x=n-1 //3: x=m-1 # include <stdio.h> long long max(long long x,long long y) { return x>y? x:y; } int main() { long long n,m,k,sum,t,ans; scanf("%lld%lld%lld",&n,&m,&k); sum=n+m-2…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 设最后行分成了x行,列分成了y列. 那么答案就是floor(n/x)floor(n/y) 然后x+y-2=k //即平均分配x行.y列 我们可以枚举floor(n/x)的值 这个值其实就是n整除x 我们现在证明n/x的结果最多只可能有2sqrt(n)个 证明: 当x小于\(\sqrt{n}\)时,n/x的值有\(\sqrt{n}\)个. 当x大于\(\sqrt{n}\)时,n/x的结果肯定小于\(\sqrt{n}\),因此也只可能有\(\…
codeforces 627 D. Preorder Test 二分 + 树dp 做logn次树dp codeforces 578D.LCS Again 给出一个字符串str,长度n<=10^6,由m种字符组成,问有多少个长度为n,与str的LCS 为 n-1的字符串t 这道题可以用dp套dp,但是我不会阿 可以找规律统计,考虑: 1.取哪个位置 2.放在哪个位置 3.放什么字符 可以知道,如果str分成了block份,每一份的字符相同,则 ans = block * n * (m - 1) 但…
今天老师(orz sansirowaltz)让我们做了很久之前的一场Codeforces Round #257 (Div. 1),这里给出A~C的题解,对应DIV2的C~E. A.Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has a big rectangular cho…
/* http://codeforces.com/problemset/problem/449/C cf 449 C. Jzzhu and Apples 数论+素数+贪心 */ #include <cstdio> #include <algorithm> using namespace std; ; int is_prime[Nmax]; int book[Nmax]; int cnt[Nmax]; int n,ans; void get__prime() { ;i<=n;i…
A - Jzzhu and Children 找到最大的ceil(ai/m)即可 #include <iostream> #include <cmath> using namespace std; int main(){ int n,m; cin >> n >> m; ; ; ; i < n; ++ i){ cin >> a; if(maxv <= ceil(a/m)){ maxv = ceil(a/m); maxIdx = i+;…
A - Jzzhu and Children Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th…
题目链接 B. Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital…
题目是来自HZW的博客(构造题我是各种不会...) Solved 1 / 1 A CodeForces 500A New Year Transportation Solved 1 / 1 B CodeForces 437C The Child and Toy Solved 1 / 2 C CodeForces 510C Fox And Names Solved 1 / 3 D CodeForces 475B Strongly Connected City Solved 1 / 2 E CodeF…