
ACM
柠栀凉
爱疯爱笑爱胡闹
展开
-
2018 百度之星 初赛B-1001 degree
可能出现的最大度数=目前度数最大值+森林个数-1+min(m-目前最大度数,k);#include <bits/stdc++.h>using namespace std;#define MAX(x,y) (x>y)?x:y#define MIN(x,y) (x<y)?x:y#define M 200010vector<int> edge[M]...原创 2018-08-14 14:21:31 · 266 阅读 · 0 评论 -
趣味魔方 右上方
规律:第一行中间数字为1,从数字1开始,它的右上方位置填数字2,依次递增第一行的上一行为最后一行,最后一列的右侧一列为第一列,若某个数字的右上方的位置已经填数字了,则它的下一个数字填在它的正下方的位置,#include <iostream>#include <iomanip>#include <string.h>using n...原创 2018-08-02 10:11:31 · 304 阅读 · 0 评论 -
2018 百度之星 B-1006
挺简单的,注意sum的类型为long long ,不然结果会错。#include <stdio.h>using namespace std;#define MIN(a,b) (a<b)?a:b#define INF 100010int main(){ int t,mx,my,n,x,y,min; long long sum; scanf("%d",&am...原创 2018-08-14 14:48:25 · 275 阅读 · 0 评论 -
日期
#include <stdio.h>const int M[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};int main(){ int year,month,day; while(~scanf("%d/%d/%d",&year,&month,&day)){ int sum=0; for(int ...原创 2018-08-02 14:35:03 · 239 阅读 · 0 评论 -
HDU 4970 Killing Monsters 树状数组
#include <bits/stdc++.h>using namespace std;#define N 100009long long c[N],sum[N],n;long long lowbit(long long x){ return (x&(-x));}void add(long long i,long long d){ while(i...原创 2019-01-25 14:54:40 · 175 阅读 · 0 评论 -
HDU 1166 敌兵布阵 树状数组
#include <bits/stdc++.h>using namespace std;const int N = 5e4 + 10;int t,n,tmp,i,j;int c[N];int lowbit(int i){ return (i&-i);}void add(int i,int data){ while(i<=n){ ...原创 2019-01-25 14:59:19 · 168 阅读 · 0 评论 -
HDU 4325 Flowers 树状数组
#include <bits/stdc++.h>using namespace std;#define NN 100009long long c[NN],n=100005;long long lowbit(long long i){ return (i&(-i));}void add(long long i,long long data){ whil...原创 2019-01-26 17:33:17 · 236 阅读 · 0 评论 -
HDU 1556 color the ball 树状数组
#include <bits/stdc++.h>using namespace std;#define N 100009int c[N],n;int lowbit(int i){ return (i&(-i));}void add(int i,int data){ while(i<=n){ c[i]+=data; i+=lowbit(i)...原创 2019-01-26 17:39:22 · 227 阅读 · 0 评论 -
HDU 6318 Swaps and inversions 树状数组
#include<iostream>#include<map>#include<algorithm>#include<cstring>#define ll long longusing namespace std;const int N = 5e5+10;int n;ll c[N];int a[N],b[N];map<...原创 2019-01-27 15:30:19 · 230 阅读 · 0 评论 -
HDU 1312 Red and black dfs
#include <iostream>#include <algorithm>#include <string.h>using namespace std;const int N=30;int w,h,step;char array[N][N];int ma[N][N];//int dir[4][2]={{0,1},{1,0},{-1,0}...原创 2019-01-28 20:42:19 · 220 阅读 · 0 评论 -
counting sheep dfs
#include <iostream>#include <string.h>#include <algorithm>#include <stdio.h>using namespace std;const int N=110;int dir[4][2]={1,0,-1,0,0,1,0,-1};int map[N][N];ch...原创 2019-01-30 14:16:50 · 320 阅读 · 0 评论 -
oil deposits dfs
#include <iostream>#include <string.h>#include <algorithm>using namespace std;const int N=110;int map[N][N];char array[N][N];int dir[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},...原创 2019-01-30 14:34:38 · 260 阅读 · 0 评论 -
hdu 1716排列2
<algorithm>头文件的next_permutation()函数 了解一下#include <stdio.h>#include <algorithm>using namespace std;int main(){ const int size=4; int a[size],tag=0; while(scanf("%d %d %d %...原创 2019-03-23 23:56:25 · 193 阅读 · 0 评论 -
南昌网络赛-1-PERFECT NUMBER PROBLEM
求前五个完数;其实前4个都很好求,但是第五个很容易超时;欧拉曾发现如此一个性质:若p是素数,且pow(2,p)-1也是素数,那么(pow(2,p)-1)*pow(2,p-1)就是一个完数。如果pow(2,p)-1是素数,称它为梅森素数,而梅森素数至今只发现了50个,所以完数的个数也不会大于50。解题思路已经很清晰了,先做一次素数筛,再把满足p是素数,且pow(2,p)-...原创 2019-04-22 15:05:55 · 514 阅读 · 0 评论 -
Common Subsequence
Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there e原创 2018-01-24 12:18:22 · 202 阅读 · 0 评论 -
C++中sort函数的用法简述
一、头文件 #include二、用法 eg:bool com(int a,int b) { return a>b;//升序 // return a } int main(){ int a[2]; sort(a,a+2,com);//com可以省略,默认升序 ......... return 0; }另一种简单写法:int原创 2018-01-17 19:50:05 · 258 阅读 · 1 评论 -
杭电problem 1000 1089 1090 1091 1092 1093
#include <iostream>using namespace std;int main(){ int t; cin>>t; int n; int i,j,sum; while(t--) { cin>>n sum=0; for(i=0;i<n;i++) { cin>>j; sum+=j...原创 2018-03-15 18:29:12 · 260 阅读 · 0 评论 -
南昌网络赛-Coloring Game
题意:2*N网格,从左上走到右下,8个方向可以移动,总共有多少种方法?第一列和最后一列:每列有2中可能;中间列:每列有3中可能;//color game#include <stdio.h>const long long mod=1e9+7;long long QuickPow(long long a,long long n){ long long ...原创 2019-04-22 17:12:55 · 377 阅读 · 0 评论