
cf
文章平均质量分 67
真的好难
因为热爱,所以才一步一步走下去。。
展开
-
cf 602 C(最短路)
C. The Two Routestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Absurdistan, there are n towns (number原创 2015-11-25 19:25:54 · 484 阅读 · 0 评论 -
cf 689 A
链接:http://codeforces.com/problemset/problem/689/A 直接将给的向量四个方向平移一次看是否有符合的#include using namespace std;#define ll long longconst int maxn=1e5+10;int n;char s[maxn],str[maxn];int flag[4]原创 2016-07-12 19:11:52 · 726 阅读 · 0 评论 -
cf 337 D(dfs)
链接:http://codeforces.com/problemset/problem/337/D 找到已经被攻击的最远距离的两个点,再遍历其他点到这两点之间的距离,当两点之间的距离都小于d,这符合题意 #include using namespace std;const int maxn=1e5+5;int n,m,d;int a[maxn],dist1[maxn],dist原创 2016-07-12 19:06:23 · 1243 阅读 · 0 评论 -
cf 432 C
链接:http://codeforces.com/problemset/problem/432/C 任意一个大于2的合数等于两个素数相加,只要知道这个定理就不难了。将每个元素的值作为下标,记录该元素所在的位置,排序的时候判断该点是否为本身,不是得话就去判断两点之间的距离是否为素数,不是变为两个素数相加即可,具体看代码#include usi原创 2016-07-12 19:01:23 · 407 阅读 · 0 评论 -
cf 75 C(gcd)
链接:http://codeforces.com/problemset/problem/75/C 求出a,b的gcd c,求出c的因子,判断是否在区间中#include using namespace std;int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int arr[10000];int main(原创 2016-07-12 18:51:24 · 441 阅读 · 0 评论 -
cf 488 B(暴力)
链接:http://codeforces.com/problemset/problem/488/B#include using namespace std;int a[10],b[10];int judge(){ sort(b,b+4); if(b[3]==3*b[0]&&b[2]+b[1]==4*b[0]) return 1; els原创 2016-07-12 18:47:39 · 239 阅读 · 0 评论 -
cf 260 C(模拟)
链接:http://codeforces.com/problemset/problem/260/C 思路:模拟往回推的过程,正常肯定超时,所以可以先将数据中的最小值取出,将每一个数都减去这个最小值,再模拟就好#include using namespace std;#define ll long longll a[100005];int main(){ ll n原创 2016-07-12 18:39:31 · 365 阅读 · 0 评论 -
cf 551 C(二分)
链接: http://codeforces.com/problemset/problem/551/C 思路:二分查找所需的时间t,m个人都有t个单位的时间,从后往前清空,直到答案最优#include using namespace std;#define ll long longint a[100005],b[100005];int main(){ in原创 2016-07-12 18:32:12 · 565 阅读 · 0 评论 -
cf 44 A
链接:http://codeforces.com/problemset/problem/44/A直接判重#include using namespace std;string s1,s2;map,int> m;int main(){ int n; scanf("%d",&n); while(n--) { cin>>s1>>s2;原创 2016-07-12 18:18:17 · 318 阅读 · 0 评论 -
cf 55A(暴力 )
链接:http://codeforces.com/problemset/problem/55/A 直接暴力 ..#include using namespace std;#define ll long longconst int maxn=100005;mapm;int main(){ int n; scanf("%d",&n); ll res原创 2016-07-12 17:45:42 · 219 阅读 · 0 评论 -
cf 689 C(二分)
链接:http://codeforces.com/problemset/problem/689/C#include using namespace std;#define ll long longll get(ll n){ ll ans=0; for(ll k=2;k*k*k<=n;k++) ans+=n/(k*k*k); return原创 2016-07-12 19:14:31 · 404 阅读 · 0 评论 -
cf 102 A(暴力)
链接:http://codeforces.com/problemset/problem/102/A#include using namespace std;int a[105],ma[105][105];int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) sca原创 2016-07-12 19:25:33 · 306 阅读 · 0 评论 -
cf 689 B(最短路)
链接:http://codeforces.com/problemset/problem/689/B #include using namespace std;#define ll long longconst int maxn=2e5+10;const int inf=(1<<30);vectorve[maxn];int n;//fuc原创 2016-07-12 19:09:41 · 662 阅读 · 0 评论 -
cf 437 D(并查集)
链接:http://codeforces.com/problemset/problem/437/D 两个集合A,B的个数分别n,m,当着两个集合通过f(a,b)连通时f(a,b)是最小的边,题目结果为n*m*f(a,b)*2 所以可以将边从大到小排序之后,用并查集维护并计算个数#include using namespace std;#define ll long lo原创 2016-07-12 19:22:26 · 355 阅读 · 0 评论 -
cf 686 B
链接:http://codeforces.com/problemset/problem/686/B#include using namespace std;int a[200];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); for(in原创 2016-07-15 21:56:26 · 1358 阅读 · 0 评论 -
cf 682 C (树形dp)
链接:http://codeforces.com/problemset/problem/682/C dp[v]表示以v为终点所需消耗的最大值 当d[v]大于a[v]时就删除以v为根节点的子树#include using namespace std;#define ll long longconst int N=1e5+5;vector >G[N];ll n,a[原创 2016-07-15 21:54:29 · 956 阅读 · 0 评论 -
cf 697 A
链接:http://codeforces.com/problemset/problem/697/A#include using namespace std;int main(){ int n,m,k; scanf("%d%d%d",&n,&m,&k); if(k<n)printf("NO\n"); else if(k==n)printf("YES原创 2016-07-15 21:50:28 · 493 阅读 · 0 评论 -
cf 697 B(模拟)
链接:http://codeforces.com/problemset/problem/697/B 直接按题意模拟。。。#include using namespace std;char s[100000],d[100000],e[100000];int main(){ int a,b; while(~scanf("%s",s)){ sscanf(s,"%d.原创 2016-07-15 21:48:48 · 695 阅读 · 0 评论 -
cf 697 C
链接:http://codeforces.com/problemset/problem/697/C 每次操作都查找两点的最近的公共祖先,查找的同时更新路径权值或者求最短路径代价#include using namespace std;#define ll long longmap,ll>m;int main(){ int n; scanf("%d",&n)原创 2016-07-15 21:47:01 · 900 阅读 · 0 评论 -
cf 686 D
链接:http://codeforces.com/problemset/problem/686/D 寻找以i为根的子树的重心 当我们要求ans[i]的时候可以发现ans[i]一定会在i节点儿子中数量最多的子树当中,所以层层往上推 直到ans[i]=i || d[i]-d[ans[i]]#include using namespace std;const int N=3e5+原创 2016-07-15 21:44:00 · 1940 阅读 · 0 评论 -
cf 681 C(模拟)
链接:http://codeforces.com/problemset/problem/681/C 优先队列去模拟#include using namespace std;priority_queue,greater >q;char s[100],ss[100];vectorv;int main(){ int n,val; scanf("%d",&n);原创 2016-07-15 21:34:01 · 1023 阅读 · 0 评论 -
cf 87 A
链接:http://codeforces.com/problemset/problem/87/A 模拟下就知道了。。#include using namespace std;#define ll long longll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}int main(){ ll a,原创 2016-07-11 09:59:02 · 306 阅读 · 0 评论 -
cf 433 C(思维题)
链接:http://codeforces.com/problemset/problem/433/C 思路:可以先计算总的消耗,接着计算将某一类型的所有数字更换成相邻的数字之后所降低消耗的最大值。。可以枚举每一个数换成相邻的数字之后减低的消耗,正常枚举肯定会超时。所以需要我们先求出每一个相邻数字的前缀和,接着枚举一个可以用o(1)的时间算出降低的消耗,具体看代码#原创 2016-07-11 09:52:29 · 532 阅读 · 0 评论 -
cf 680 c
链接:http://codeforces.com/contest/680/problem/C题意:给你一个数字,让你查询不超过20次判断是素数还是合数//判断2 -100 以内是素数还是合数 由于最多查询20次 我们可以查询20次来判断是否是素数,小于100的合数一定有因子是2,3,5,7 有可能是素数因子就是本身,所以要增加4,9,25,49,来判断是否是合数 #includ原创 2016-06-09 16:23:22 · 318 阅读 · 0 评论 -
CF 505 B (dfs)
链接:http://codeforces.com/problemset/problem/505/B#include using namespace std;int to,res,n,m;int c[105][105][105];int d[105][105];int ans[105];bool vis[105][105][105];void dfs(int v,int co)原创 2015-10-14 16:12:36 · 360 阅读 · 0 评论 -
cf 598 d
D. Igor In the Museumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIgor is in the museum and he wants to原创 2015-11-14 01:29:56 · 465 阅读 · 0 评论 -
cf 598 B
B. Queries on a Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s and should原创 2015-11-14 01:28:49 · 564 阅读 · 0 评论 -
cf 598 A
A. Tricky Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem you are to calculate the sum o原创 2015-11-14 01:28:03 · 536 阅读 · 0 评论 -
cf 580B
B. Kefa and Companytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKefa wants to celebrate his first big s原创 2015-09-23 13:32:21 · 526 阅读 · 0 评论 -
cf 580 A
A. Kefa and First Stepstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKefa decided to make some money doi原创 2015-09-23 13:29:48 · 578 阅读 · 0 评论 -
cf 567C
C. Geometric Progressiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp loves geometric progressio原创 2015-09-08 15:09:12 · 702 阅读 · 0 评论 -
cf 580 c(邻接表+dfs)
C. Kefa and Parktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKefa decided to celebrate his first big sa原创 2015-09-23 13:34:24 · 689 阅读 · 0 评论 -
cf 583 B. Robot's Task(模拟)
链接:http://codeforces.com/problemset/problem/583/B//求改变的方向次数//直接模拟 题目是从1 开始 所以从左到右 从右到左#include #include using namespace std;int a[1000+10];int vis[1000+10];int main(){ int n,t=0原创 2015-10-05 23:43:20 · 369 阅读 · 0 评论 -
cf 602 A(进制转换)
A. Two Basestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter seeing the "ALL YOUR BASE ARE BELONG TO U原创 2015-11-25 19:23:29 · 300 阅读 · 0 评论 -
cf 602 B(模拟)
B. Approximating a Constant Rangetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen Xellos was doing a p原创 2015-11-25 19:24:38 · 661 阅读 · 0 评论 -
cf 680 B
链接:http://codeforces.com/contest/680/problem/B 题意:给你n个数字,你在a的位置,问你通过题给定的。。方法可以抓到多少个小偷//直接从a点开始向两边枚举#include using namespace std;int a[200];int main(){ int n,m; while(~s原创 2016-06-09 16:01:09 · 346 阅读 · 0 评论 -
cf 680 A
链接:http://codeforces.com/contest/680/problem/A 题意: 5个数字求删除2个相同或者3个相同之后剩下值之和的最小值//枚举每种情况找最小值#include using namespace std;int a[10];int main(){ int sum=0; for(int i=0;i<5;i++)原创 2016-06-09 15:57:52 · 328 阅读 · 0 评论 -
cf 185A(矩阵快速幂)
A. Planttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDwarfs have planted a very interesting plant, whic原创 2016-05-19 21:07:32 · 670 阅读 · 0 评论 -
cf 675 D
D. Tree Constructiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the programming classes Vasya w原创 2016-05-24 16:21:58 · 379 阅读 · 0 评论 -
cf 675 B
B. Restoring Paintingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya works as a watchman in the galle原创 2016-05-24 16:02:39 · 339 阅读 · 0 评论