自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(184)
  • 收藏
  • 关注

原创 考研数据结构

线性表是具有相同数据类型的n(n>=0)个数据元素的有限序列,其中n为表长,当n=0时线性表是一个空表。线性表中的元素具有逻辑上的顺序性,除了表头和表尾外,每个元素在逻辑上都有一个前驱和后继元素。。

2023-12-05 15:43:26 890

原创 springboot笔记总结

springboot的简单内容笔记

2022-09-15 15:13:54 407

原创 组合数学(持续更新)

文章目录排列与组合四个基本计数原理集合的排列排列与组合四个基本计数原理(1)(1)(1) 加法原理: 设集合 SSS 被划分成两两不相交的部分 S1S_1S1​, S2S_2S2​ … SmS_mSm​, 则 SSS的对象数目可以通过确定它的每一个部分的对象数目并如此相加而得到 :∣S∣=∣S1∣+∣S2∣+...+∣Sm∣{\vert S \vert} = {\vert S_1 \vert} + {\vert S_2 \vert} +...+ {\vert S_m \vert}∣S∣=

2021-09-03 22:23:12 929 4

原创 Wonderful Coloring - 1

题目:题目链接:题解:#include <bits/stdc++.h>using namespace std;int main(){ int t; cin>>t; while(t--) { string a; cin>>a; int con[30]={0}; for(int i=0;a[i];i++) { con[a[i]-'

2021-08-13 21:41:45 207

原创 Polycarp and Coins

题目:题目链接:题解:#include <bits/stdc++.h>using namespace std;int main(){ int t; cin>>t; while(t--) { long long n; cin>>n; long long a=n/3,b=n/3; int c=n%3; if(c==1) a++; else

2021-08-13 21:40:41 166

原创 Moamen and k-subarrays

题目:题目链接题解:#include <bits/stdc++.h>using namespace std;const int N=1e6+10;long long a[N],b[N];map<long long, long long> c;int main(){ int t; cin>>t; while(t--) { c.clear(); long long n,k; cin>>n>>k; for(int

2021-08-13 21:36:29 111

原创 Ezzat and Two Subsequences

题目:题目链接题解:#include <bits/stdc++.h>using namespace std;const int N=1e6+10;long long a[N];int main(){ int t; cin>>t; while(t--) { long long n; cin>>n; long long sum=0; long long ma=-1e9-10; for(int i=1;i<=n;i++) cin

2021-08-13 21:35:24 110

原创 P2953 [USACO09OPEN]Cow Digit Game S

题目:题目链接题解:#include <bits/stdc++.h>using namespace std;const int N=1e6+10;int f[N];int ma(int x){ int ans=0; while(x) { int d=x%10; ans=max(ans, d); x/=10; } return ans;}int mi(int x){ int ans

2021-08-13 21:34:00 84

原创 P1488 肥猫的游戏

题目:题目链接题解:#include <bits/stdc++.h>using namespace std;int main(){ int n; cin>>n; int r=0; int m=n-2; int a,b,c; cin>>a>>b>>c; int s[5]={a,b,c}; sort(s,s+3); if(s[0]+1==s[1]&&s[

2021-08-13 21:31:40 91

原创 P1447 [NOI2010] 能量采集

题目:题目链接题解:#include <bits/stdc++.h>using namespace std;long long pri(int n){ long long ans=n; for(int i=2;i<=n/i;i++) { if(n%i==0) { ans=(long long)ans*(i-1)/i; while(n%i==0) n/=i; }

2021-08-13 21:30:27 71

原创 P1290 欧几里德的游戏

题目:题目链接题解:#include <bits/stdc++.h>using namespace std;int con;int c(long long n,long long m)//n<m{ if(n==0) return false; else if(m/n==1) return !c(m%n,n); else return true;}int main(){ int t; cin>>t; while

2021-08-13 21:29:09 100

原创 P1247 取火柴游戏

题目:题目链接题解:#include <bits/stdc++.h>using namespace std;long long a[500005];int main(){ int n; cin>>n; long long ans=0; for(int i=1;i<=n;i++) { cin>>a[i]; ans^=a[i]; } if(ans) {

2021-08-13 21:27:41 60

原创 P1100 高低位交换

题目:题目链接题解:#include <bits/stdc++.h>using namespace std;int main(){ long long x; cin>>x; cout<<((x&0x0000ffff)<<16|(x&0xffff0000)>>16)<<endl; return 0;}

2021-08-13 21:26:12 91

原创 矩阵距离(多源bfs)

题目:题目链接:题解:#include <bits/stdc++.h>using namespace std;int n,m;char pos[1005][1005];int dis[1005][1005];int dx[4]={0,0,1,-1};int dy[4]={1,-1,0,0};typedef pair<int,int> pll;void bfs(){ memset(dis,-1,sizeof dis); queue<pll&

2021-08-08 22:23:41 62

原创 魔板(最小步数)

题目:题目链接:题解:#include <bits/stdc++.h>using namespace std;string st,en;map<string,int> dis;map<string,pair<char,string>> pre;queue<string> q;string move0(string a){ string ans; for(int i=7;i>=0;i--) ans+=a[i]

2021-08-08 22:22:25 63

原创 Hankson的趣味题

题目:题目链接:题解:#include <bits/stdc++.h>using namespace std;const int N=45000;int pri[N],primes[N];int con,conf,cond;typedef pair<int,int> pll;pll f[N];int yueshu[N];void prime(){ for(int i=2;i<=N;i++) { if(!pri[i]) p

2021-08-08 22:19:51 81

原创 青蛙的约会

题目:题目链接:题解:同余方程#include <bits/stdc++.h>using namespace std;long long exgcd(long long a,long long b,long long &x,long long &y){ if(b==0) { x=1; y=0; return a; } long long gcd=exgcd(b,a%b,y,x);

2021-08-08 22:18:15 60

原创 曹冲养猪(同余)

题目:题目链接:题解:同余方程#include <bits/stdc++.h>using namespace std;typedef long long ll;ll exgcd(ll a,ll b,ll &x,ll &y){ if(b==0) { x=1; y=0; return a; } ll gcd; gcd=exgcd(b,a%b,y,x); y-=a/b*x;

2021-08-08 22:16:50 109

原创 数三角形(组合数学)

题目:题目链接:题解:#include <bits/stdc++.h>using namespace std;typedef long long ll;long long c(int n){ long long ans=((ll)n*(n-1)*(n-2))/6; return ans;}int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int main(){ int n,m; cin

2021-08-08 22:15:35 141

原创 xay loves count

题目:题目链接:题解:#include <bits/stdc++.h>using namespace std;#define int long longconst int maxn=1e6;int a[maxn+5],b[maxn+5];signed main(){ int n,ans=0,s1=0; scanf("%lld",&n); for (int i = 0; i < n; ++i) { int x;

2021-08-08 22:12:42 91

原创 xay loves or

题目:题目链接:题解:坑点: yyy 是正整数#include <bits/stdc++.h>using namespace std;int main(){ long long x,s; cin>>x>>s; if(x>s) cout<<0<<endl; else { long long ans=1; for(int i=0;i<32;i++)

2021-08-08 22:04:50 52

原创 一个简单的整数问题2

题目:题目链接题解:树状数组#include <bits/stdc++.h>using namespace std;long long a[100005],t1[100005],t2[100005],sum[100005];int n;void add1(int x, int k){ for(; x <= n; x += x & -x) t1[x] += k;}long long ask1(int x){ long long ans = 0;

2021-08-05 00:45:12 57

原创 一个简单的整数问题

题目:题目链接:题解:树状数组#include <bits/stdc++.h>using namespace std;long long a[100005],t[100005];int n;void add(int x, int k){ for(; x <= n; x += x & -x) t[x] += k;}long long ask(int x){ long long ans = 0; for(; x; x -= x &

2021-08-05 00:43:34 76

原创 楼兰图腾题解

题目:题目链接:题解:树状数组#include <bits/stdc++.h>using namespace std;const int N = 2e5+10;long long a[N];long long t[N];long long bigger[N],lower[N];int n;void add(long long x, long long k){ for(; x <= n; x += x & -x) t[x] += k;}long l

2021-08-05 00:42:18 88

原创 Segment Tree with Pruning

题目题目链接:题解:记忆化搜索#include <bits/stdc++.h>using namespace std;map<long long,long long>p;long long slove(long long n,long long k){ if(n<=k) return 1; if(p[n]!=0) return p[n]; if(n%2==0) { p[n]=2*slove(n/2,k)+1; } else {

2021-08-05 00:40:44 101

原创 Intervals on the Ring

题目:题目链接:题解:using namespace std;int t,n,m;struct node{ int l,r;}a[1005];bool cmp(node x,node y){ return x.l<y.l;}int main(){ cin>>t; while(t--) { cin>>n>>m; for(int i=0;i<m;i++)cin>>a[i].l>>a[i].r; s

2021-08-03 01:24:58 52

原创 Web of Lies

题目:题目链接:题解:#include <bits/stdc++.h>using namespace std;int g[200005];int main(){// int t;// cin>>t;// while(t--)// { //memset(g,0,sizeof g); int n,m; cin>>n>>m; int ans=0; for(int i=1;i<=m;i++) { int u,v

2021-08-03 00:33:50 91

原创 Gregor and the Pawn Game

题目:题目链接:题解:从左向右看,如果前面有 111 便先向左上角找,然后向右上角找#include <bits/stdc++.h>using namespace std;int main(){ int t; cin>>t; while(t--) { int n; cin>>n; string a,b; cin>>a>>b; int ans=0; for(int i=0;i<n;i++) {

2021-08-02 22:24:10 285

原创 Gregor and Cryptography

题目:题目链接:题解:质数一定是奇数,所以选择 p−1p-1p−1 和 p/2p/2p/2#include <bits/stdc++.h>using namespace std;int main(){ int t; cin>>t; while(t--) { long long n; cin>>n; cout<<n/2<<" "<<n-1<<endl; } return 0;}..

2021-08-02 22:21:43 153

原创 2021牛客暑期多校训练营3

文章目录B--Black and whiteE--MathJ--Counting TrianglesB–Black and white题目链接:题解:#include<bits/stdc++.h>#define ll long longusing namespace std;const int maxn = 5005;struct node { int u,v; ll w; bool operator < (const node&

2021-07-31 23:55:03 82

原创 2021牛客暑期多校训练营4

题目:题目链接题意:LCS(s1,s2)LCS(s1,s2)LCS(s1,s2)表示 s1s1s1 和 s2s2s2 的最长公共子序列给定三个字符串 s1s1s1, s2s2s2,s3s3s3,要求满足 LCS(s1,s2)=aLCS(s1,s2) = aLCS(s1,s2)=a, LCS(s2,s3)=bLCS(s2,s3) = bLCS(s2,s3)=b, LCS(s1,s3)=cLCS(s1,s3) = cLCS(s1,s3)=c输出满足要求的 s1,s2,s3s1,s2,s3s1,s2

2021-07-31 13:54:45 89

原创 2021牛客暑期多校训练营2

文章目录C--Draw GridsD--Er Ba GameC–Draw Grids题目链接:题意:总共有 n∗mn*mn∗m 个点, 两人轮流选取两个点连一条线, 不能连已经连过的线, 并且连成的图形不能形成闭合回路, 两人都选取最优策略,最后不能操作的人输题解:判断奇偶性就好#include <bits/stdc++.h>using namespace std;int main(){ int n,m; cin>>n>>m

2021-07-25 23:11:58 114 1

原创 2021牛客暑期多校训练营1

文章目录Alice and BobBall Dropping在补了....Alice and Bob题目链接:题意:总共有两堆石头,每次可以从一堆中取走 kkk (k>0)(k>0)(k>0)块石头,从另一堆取走 s∗ks*ks∗k (s>=0)(s>=0)(s>=0)块石头, 不能操作的人输题解:用一个二维数组 f[i][j]f[i][j]f[i][j] 储存状态, f[i][j]f[i][j]f[i][j] 为 111 代表有两堆石头分别有i

2021-07-23 22:12:46 131

原创 I love exam

题目:题目链接:题解:参考:链接:f[i][j]f[i][j]f[i][j] 表示第 iii 门课程,花费 jjj 天可以得到的最大分数dp[i][j][k]dp[i][j][k]dp[i][j][k] 表示前 iii 门课,花费 jjj 天, 挂 kkk 门课可以得到的最大分数记得初始化转移:f[i][z]<60f[i][z]<60f[i][z]<60dp[i][j][k]=max(dp[i][j][k],dp[i−1][j−z][k−1]+f[i][z])dp[i][

2021-07-23 17:59:24 117

原创 KD-Graph

题目:链接题意:总共有 nnn 个点,mmm条边,要分成 kkk 组,满足(1)(1)(1) 如果顶点 p 和 q ( p ≠ q ) 在同一组中,则 p 和 q 之间必须至少有一条路径满足该路径中的最大值小于或等于 D。(2)(2)(2) 如果顶点 p 和 q ( p ≠ q ) 在不同的组中,则 p 和 q 之间不可能有任何路径满足该路径中的最大值小于或等于 D。题解:最开始分为cnt=ncnt=ncnt=n个组按找点的边权从小到大排序, 如果这两个点不在同一个集合中,则将它们合并到一个

2021-07-23 16:32:53 130

原创 P2257 YY的GCD

题目:题目链接:题解:莫比乌斯反演#include <bits/stdc++.h>#define N 10000010using namespace std;long long pri[N],cnt,g[N];bool st[N];long long mu[N],sum[N];void get_mu(){ mu[1]=1; for(long long i=2;i<N;i++) { if(!st[i]){mu[i]=-1;pri

2021-05-24 22:25:43 55

原创 P1829 [国家集训队]Crash的数字表格 / JZPTAB

题目:题目链接:题解:莫比乌斯反演#include <bits/stdc++.h>using namespace std;long long mod=20101009;const int N=1e7+10;long long mu[N],pri[N],con,sum[N];bool st[N];long long n,m;void getmus(){ mu[1]=1; for(int i=2;i<=N;i++) { if(!

2021-05-24 22:19:07 59

原创 P4450 双亲数

题目:题目链接:题解:莫比乌斯反演即求∑i=1n∑j=1m[gcd(i,j)=k]\sum_{i=1}^{n} \sum_{j=1}^{m} {[gcd(i,j)=k]}∑i=1n​∑j=1m​[gcd(i,j)=k]∑i=1n∑j=1m[gcd(i,j)=k]\sum_{i=1}^{n} \sum_{j=1}^{m} {[gcd(i,j)=k]}∑i=1n​∑j=1m​[gcd(i,j)=k]=∑i=1[n/k]∑j=1[m/k][gcd(i,j)=1]\sum_{i=1}^{[n/k]} \

2021-05-22 21:43:26 80

原创 2020ICPC 江西省大学生程序设计竞赛 A Simple Math Problem

题目:题目链接:题解:莫比乌斯反演推导过程如下∑i=1n∑j=1iF[j][gcd(i,j)=1]\sum_{i=1}^{n}\sum_{j=1}^{i} {F[j][gcd(i,j)=1]}∑i=1n​∑j=1i​F[j][gcd(i,j)=1]可以转化为 ∑i=1nF[i]∑j=ingcd[(i,j)=1]\sum_{i=1}^{n}{F[i]} \sum_{j=i}^{n} {gcd[(i,j)=1]}∑i=1n​F[i]∑j=in​gcd[(i,j)=1]∑i=1nF[i]∑j

2021-05-22 21:32:33 326

原创 区间选点

题目:题解:贪心,根据右端点排序#include <bits/stdc++.h>using namespace std;struct node { long long a,b;}p[100005];bool cmp(node x,node y){ return x.b<y.b;}int main(){ int n; cin>>n; for(int i=0;i<n;i++) { cin

2021-05-21 23:15:25 69

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除