上一页 1 ··· 7 8 9 10 11 12 13 14 下一页
摘要: #include <cstdio> #include <cstring> #include <vector> using namespace std; int main(){ int a[210000],flag[210000],lag[210000],n; vector<int> vec; mem 阅读全文
posted @ 2017-10-02 20:03 LMissher 阅读(187) 评论(0) 推荐(0)
摘要: #include <cstdio> int main(){ long long a,b,f,k,i,tot,s[11000],cnt; scanf("%lld%lld%lld%lld",&a,&b,&f,&k); tot=0,s[tot]=0,cnt=0; while(cnt<k*a){ tot++ 阅读全文
posted @ 2017-10-02 20:00 LMissher 阅读(111) 评论(0) 推荐(0)
摘要: #include <cstdio> #include <map> using namespace std; int main(){ int n,tot,max=0; map<char,int> mp; char a[210]; scanf("%d",&n); scanf("%s",a); for(i 阅读全文
posted @ 2017-10-02 19:57 LMissher 阅读(137) 评论(0) 推荐(0)
摘要: 题意:给你n个数再给一个数字K,问你最少多少个操作能让K前的数字都存在,K不存在。 题解:先删除所有的K,再补完前面缺少的数字。 代码: #include <cstdio>int N, cnt[101], K, O;int main(){ scanf("%d%d", &N, &K); for (in 阅读全文
posted @ 2017-09-20 13:43 LMissher 阅读(84) 评论(0) 推荐(0)
摘要: 题意:给你一个树形的二分图,问最多可以添加多少条边让其始终为二分图。 题解:利用二分图的染色判断出两个集合中各有多少个数,总的边数应该为两个集合顶点数乘积,所以输出乘积减n-1就可以了。 PS:注意要用long long,因为这个比赛的时候WA了无数发。。。 代码: # include<iostre 阅读全文
posted @ 2017-09-20 13:07 LMissher 阅读(114) 评论(0) 推荐(0)
摘要: 题目:一个人要买房,一共有n间在一排的房,有k间已经售出。但这个人只想买旁边有人居住的房,问最多有多少选择,最少有多少选择。 题解:当k==0或k==n时,max==min==0。一般情况时三个为一组,k--,tot+=2,n-=3;当n<3时,tot+=(n-k)。 代码: #include<cs 阅读全文
posted @ 2017-09-12 15:08 LMissher 阅读(228) 评论(0) 推荐(0)
摘要: 题目:最小生成树裸题。 注意getchar的使用。 代码: #include<cstdio>#include<cstring>#include<algorithm>using namespace std;int per[110];struct node{ char a,b; int w;}s[100 阅读全文
posted @ 2017-09-12 14:55 LMissher 阅读(117) 评论(0) 推荐(0)
摘要: 题目:裸的Floyd。 代码: #include <cstdio>const int inf=1<<29;int n,m;int a[500];int dp[500][500];void floyd(){ for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for 阅读全文
posted @ 2017-09-12 13:37 LMissher 阅读(181) 评论(0) 推荐(0)
摘要: 题目:有两组数目相同的数,数目可以顺序移动。每组数从1到n进行ai-bi并求和,当和小于0时停止,并把之前的ai求和输出,求最大的ai求和。 题解:把两组数复制并延长一倍。一个循环搞定。 ps:第一道自己做出的网络赛题目,继续努力! 代码: #include<cstdio>int a[1100000 阅读全文
posted @ 2017-09-12 13:32 LMissher 阅读(94) 评论(0) 推荐(0)
摘要: 题意:有n个点m条边,求用边把所有点连接起来的最小权值。 题解:当m小于n-1时是不可能的,当有自环时也不可能,排除掉这两个情况然后用Kruskal。 代码: #include <cstdio>#include <algorithm>using namespace std;int n,m,f[110 阅读全文
posted @ 2017-08-22 11:11 LMissher 阅读(130) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 下一页