-
个人简介
!!!唉!!! !!!愁!!!
!!! 啊~啊~啊~ !!!
!!! 忧虑~ !!!
现主页总字数:54598.
有点少 (> ~ <)
洛谷
NOI
知识点
三个最短路模版
Dijkstra 模版
#include <bits/stdc++.h> using namespace std; int d[10001]; bool vis[10001]; struct node{ int u,v; }; vector<node> g[10001]; struct nod{ int d,id; bool operator <(nod a) const{ return d>a.d; } }; priority_queue<nod>q; int n,m; void dij(int s){ d[1]=0; q.push((nod){0,1}); while(!q.empty()){ int u=q.top().id; q.pop(); vis[u]=true; for(int i=0;i<g[u].size();i++){ int u=g[u][i].u; int v=g[u][i].v; if(vis[u]) continue; if(d[u]+v<d[u]){ d[u]=d[u]+v; q.push((nod){d[u],u}); } } } } int main(){ memset(d,127,sizeof(d)); cin>>n>>m; while(m--){ int x,y,u; cin>>x>>y>>u; g[x].push_back((node){y,u}); } dij(1); cout<<d[n]; } /* #include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> PII; const int N=1000005; int n,m,h[N],e[N],ne[N],w[N],idx; bool st[N]; int dist[N]; void add (int u,int v,int c){ e[idx]=v; w[idx]=c; ne[idx]=h[u]; h[u]=idx++; } int dij(){ memset(dist,0x3f,sizeof dist); dist[1]=0; priority_queue<PII,vector<PII>,greater<PII>> heap; heap.push({0,1}); while(heap.size()){ auto t=heap.top(); heap.pop(); int ver=t.second,distance=t.first; if(st[ver]) continue; st[ver]=true; for(int i=h[ver];i!=-1;i=ne[i]){ int j=e[i]; if(dist[ver]+w[i]<dist[j]){ dist[j]=dist[ver]+w[i]; heap.push({dist[j],j}); } } } if(dist[n]==0x3f3f3f3f) return -1; return dist[n]; } main(){ cin>>n>>m; memset(h,-1,sizeof h); while(m--){ int u,v,z; cin>>u>>v>>z; add(u,v,z); } cout<<dij(); } */spfa 模版
#include<bits/stdc++.h> using namespace std; const int N=1000005; int h[N],w[N],e[N],ne[N]; int dist[N]; bool st[N]; int n,m,idx; void add(int u,int v,int c){ e[idx]=v; w[idx]=c; ne[idx]=h[u]; h[u]=idx++; } int spfa(){ memset(dist,0x3f,sizeof dist); dist[1]=0; queue<int>q; q.push(1); st[1]=true; while(q.size()){ int t=q.front(); q.pop(); st[t]=false; for(int i=h[t];i!=-1;i=ne[i]){ int j=e[i]; if(dist[t]+w[i]<dist[j]){ dist[j]=dist[t]+w[i]; if(!st[j]){ q.push(j); st[j]=true; } } } } return dist[n]; } main(){ cin>>n>>m; memset(h,-1,sizeof h); while(m--){ int u,v,z; cin>>u>>v>>z; add(u,v,z); } int t = spfa(); if(t==0x3f3f3f3f) cout<<"impossible"; else cout<<dist[n]; }floyd 模版
#include<bits/stdc++.h> using namespace std; int n,m,k; int a[109][109]; void floyd(){ for(int k=1;k<=n;k++){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ a[i][j]=min(a[i][j],a[i][k]+a[k][j]); } } } } int main(){ memset(a,0x3f3f3f3f,sizeof a); cin>>n>>m; for(int i=1;i<=m;i++){ int u,v,z; cin>>u>>v>>z; a[u][v]=min(a[u][v],z); } floyd(); cin>>k; while(k--){ int u,v; cin>>u>>v; cout<<a[u][v]<<endl; } return 0; } /* #include<bits/stdc++.h> using namespace std; const int INF=1e9; int n,m,k; int a[250][250]; void floyd(){ for(int k=1;k<=n;k++){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ a[i][j]=min(a[i][j],a[i][k]+a[k][j]); } } } } main(){ cin>>n>>m>>k; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==j) a[i][j]=0; else a[i][j]=INF; } } for(int i=1;i<=m;i++){ int u,v,z; cin>>u>>v>>z; a[u][v]=min(a[u][v],z); } floyd(); while(k--){ int u,v; cin>>u>>v; if(a[u][v]>(long long)INF/2) cout<<"impossible"<<"\n"; else cout<<a[u][v]<<"\n"; } } */CSP-J 真题
1.小苹果
#include<bits/stdc++.h> using namespace std; int n,s,sum; //按组划分,用 除 或者 余 之类 main(){ cin>>n; while(n){ s++; //天数增加 if(n%3==1&&sum==0) sum=s; //拿苹果 if(n%3==0) n-=n/3; else n-=n/3,n--; //向上取整 } cout<<s<<" "<<sum; }2.公路
#include<bits/stdc++.h> using namespace std; const int N=100050; long long n,m,sum,a[N],b[N],s[N],minn=N,t; main(){ cin>>n>>m; //距离 for(int i=1;i<n;i++) cin>>a[i],s[i]=s[i-1]+a[i]; //s[] 累加到达站点 //站点油费 for(int i=1;i<n;i++) cin>>b[i]; //模拟每一段路 minn=b[1]; //计算距离 多少升油*m; t= (a[1]+m-1)/m*m; //费用//向上取整:ceil() sum=(a[1]+m-1)/m*minn; //第二段路 for(int i=2;i<n;i++){ if(b[i]<minn) minn=b[i]; //还需不需要加油 去到下一段路还够不够油 if(t<s[i]){ //加多少油 sum+= ((s[i]-t+m-1)/m)*minn; t+= ((s[i]-t+m-1)/m)*m; } } cout<<sum; }3.扑克牌 (两种方法都可以)
#include<bits/stdc++.h> using namespace std; string k; map<string,int>mp; int n,o; main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>k; if(mp[k]==0){ mp[k]=++o; } } cout<<52-o; } /* #include<bits/stdc++.h> using namespace std; set<string>q; int n; string k; main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>k; q.insert(k); } cout<<52-q.size(); } */4.地图探险
#include<bits/stdc++.h> using namespace std; const int N=1050; char g[N][N]; int t,n,m,k,x,y,d,sum; bool vis[N][N]; main(){ //数据数量 cin>>t; while(t--){ //初始地图 cin>>n>>m>>k; //初始信息 cin>>x>>y>>d; //地图 for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) cin>>g[i][j]; } //初始值 sum=1; memset(vis,false,sizeof vis); vis[x][y]=true; //模拟次数 int nx,ny; for(int i=1;i<=k;i++){ //方向判断下一步 if(d==0) nx=x,ny=y+1; else if(d==1) nx=x+1,ny=y; else if(d==2) nx=x,ny=y-1; else if(d==3) nx=x-1,ny=y; //判断下一步满不满足条件 if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&g[nx][ny]=='.'){ if(vis[nx][ny]!=true) sum++; x=nx,y=ny; vis[nx][ny]=true; } else d=(d+1)%4; } cout<<sum<<"\n"; } }5.小木棍
#include<bits/stdc++.h> using namespace std; // 不同数量的木棍数量 存储 int sum[11]={6,2,5,5,4,5,6,3,7,6}; int n,t; main(){ cin>>n; while(n--){ cin>>t; //打表分析 //个位不能用贪心 if(t==1) {cout<<"-1\n"; continue;} if(t==2) {cout<<"1\n" ; continue;} if(t==3) {cout<<"7\n" ; continue;} if(t==4) {cout<<"4\n" ; continue;} if(t==5) {cout<<"2\n" ; continue;} if(t==6) {cout<<"6\n" ; continue;} if(t==7) {cout<<"8\n" ; continue;} //两位数就可以贪心 if(t%7==0) for(int i=1;i<=t/7;i++) cout<<8; else if(t%7==1){cout<<10; for(int i=1;i<=(t-8)/7;i++) cout<<8;} else if(t%7==2){cout<<1; for(int i=1;i<=(t-2)/7;i++) cout<<8;} else if(t%7==3){ if(t==10) {cout<<"22";} else {cout<<200;for(int i=1;i<=(t-17)/7;i++) cout<<8;} } else if(t%7==4){cout<<20; for(int i=1;i<=(t-11)/7;i++) cout<<8;} else if(t%7==5){cout<<2; for(int i=1;i<=(t-5)/7;i++) cout<<8;} else if(t%7==6){cout<<6; for(int i=1;i<=(t-6)/7;i++) cout<<8;} cout<<"\n"; } }6.上升点列
#include<bits/stdc++.h> using namespace std; const int N=1005; pair<int,int> a[N]; int n,k,x,y,sum; int dp[N][N]; main(){ cin>>n>>k; for(int i=1;i<=n;i++){ cin>>a[i].first>>a[i].second; } //pair 默认对 first 排序 sort(a+1,a+1+n); //dp[以什么为结尾的][用了多少个k] = 最长长度 //转移 1-n 个结尾进行dp for(int i=1;i<=n;i++){ //k个选择 for(int j=0;j<=k;j++){ //如果接不上 自己的点 + 可以添加的点数 dp[i][j]=j+1; //dp[o] 考虑借上谁 // a[i] 接 a[o] for(int o=1;o<=i-1;o++){ int dst = a[i].first-a[o].first+a[i].second-a[o].second-1; if(a[i].second>=a[o].second&&dst<=j&&dp[i][j]<dp[o][j-dst]+dst+1) dp[i][j]=dp[o][j-dst]+dst+1; } } sum=max(sum,dp[i][k]); }#include<bits/stdc++.h> using namespace std; const int N=1005; pair<int,int> a[N]; int n,k,x,y,sum; int dp[N][N]; main(){ cin>>n>>k; for(int i=1;i<=n;i++){ cin>>a[i].first>>a[i].second; } //pair 默认对 first 排序 sort(a+1,a+1+n); //dp[以什么为结尾的][用了多少个k] = 最长长度 //转移 1-n 个结尾进行dp for(int i=1;i<=n;i++){ //k个选择 for(int j=0;j<=k;j++){ //如果接不上 自己的点 + 可以添加的点数 dp[i][j]=j+1; //dp[o] 考虑接上谁 // a[i] 接 a[o] for(int o=1;o<=i-1;o++){ int dst = a[i].first-a[o].first+a[i].second-a[o].second-1; if(a[i].second>=a[o].second&&dst<=j&&dp[i][j]<dp[o][j-dst]+dst+1) dp[i][j]=dp[o][j-dst]+dst+1; } } sum=max(sum,dp[i][k]); } cout<<sum; }7.方格取数
#include<bits/stdc++.h> using namespace std; #define int long long //状态转移方程: //dp[行][列] = 最大值 const int N=1005,INF=0x3f3f3f3f; int n,m,a[N][N]; int dp[N][N],up[N],dow[N]; signed main(){ cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>a[i][j]; } } //初始化 memset(dp,-INF,sizeof dp); dp[0][1]=0; //dp第一列 for(int i=1;i<=n;i++) dp[i][1]=dp[i-1][1]+a[i][1]; for(int i=2;i<=m;i++){ //算出 1-n 列的和 dow dow[0]=-INF; for(int j=1;j<=n;j++){ dow[j]=max(dp[j][i-1],dow[j-1])+a[j][i]; } up[n+1]=-INF; //算出 n-1 列的和 up for(int j=n;j>=1;j--){ up[j]=max(dp[j][i-1],up[j+1])+a[j][i]; } for(int j=1;j<=n;j++){ dp[j][i]=max(dow[j],up[j]); } } cout<<dp[n][m]; }8.密码锁
#include<bits/stdc++.h> using namespace std; int n,a,b,c,d,e,s[30][30][30][30][30],sum=0; main(){ cin>>n; int t=n; while(n){ cin>>a>>b>>c>>d>>e; n--; //00115->11115 //11115 for(int i=1;i<=9;i++){ s[(a+i)%10][b][c][d][e]++; s[a][(b+i)%10][c][d][e]++; s[a][b][(c+i)%10][d][e]++; s[a][b][c][(d+i)%10][e]++; s[a][b][c][d][(e+i)%10]++; s[(a+i)%10][(b+i)%10][c][d][e]++; s[a][(b+i)%10][(c+i)%10][d][e]++; s[a][b][(c+i)%10][(d+i)%10][e]++; s[a][b][c][(d+i)%10][(e+i)%10]++; } } for(int i=0;i<=9;i++){ for(int j=0;j<=9;j++){ for(int k=0;k<=9;k++){ for(int l=0;l<=9;l++){ for(int o=0;o<=9;o++){ if(s[i][j][k][l][o]==t){ //cout<<i<<j<<k<<l<<o<<endl; sum++; } } } } } } cout<<sum; }9.接龙
#include<bits/stdc++.h> using namespace std; const int R=105; const int N=1e5+5; const int M=2e5+5; int t,n,k,q,f[R][M]; vector<int>g[N]; //核心 void solve(){ //初始化 memset(f,-1,sizeof f); f[0][1]=0; for(int r=1;r<=100;r++){ //轮数 for(int i=1;i<=n;i++){ //第i个人 int len=0; for(int j=0;j<g[i].size();j++){ //第i个人的整数序列 int c=g[i][j]; if(len>0){ if(f[r][c]==-1) f[r][c]=i; else if(f[r][c]!=i) f[r][c]=0; len--; } if(f[r-1][c]!=-1&&f[r-1][c]!=i){ len=k-1; } } } } } void Main(){ cin>>n>>k>>q; for(int i=1;i<=n;i++){ g[i].clear(); int len; cin>>len; for(int j=1;j<=len;j++){ int x; cin>>x; g[i].push_back(x); } } solve(); for(int i=1;i<=q;i++){ int r,c; cin>>r>>c; if(f[r][c]==-1) cout<<0<<"\n"; else cout<<1<<"\n"; } } main(){ cin>>t; while(t--){ Main(); } }10.旅游巴士
//同余最短路 #include<bits/stdc++.h> using namespace std; const int N=1e5+5,M=2e4+5; struct edge{ int v,w; }; vector<edge> g[N]; //优先队列 struct node{ int u,r,d; bool operator<(node rhs)const{ return d>rhs.d; } }; priority_queue<node> q; // int n,m,k,vis[N][105],f[N][105]; main(){ cin>>n>>m>>k; for(int i=1;i<=m;i++){ int u,v,w; cin>>u>>v>>w; g[u].push_back((edge){v,w}); } memset(f,127,sizeof f); f[1][0]=0; q.push((node){1,0,0}); while(!q.empty()){ int u=q.top().u,r=q.top().r,d=q.top().d; q.pop(); if(vis[u][r]) continue; vis[u][r]=true; for(int i=0;i<g[u].size();i++){ int v=g[u][i].v,w=g[u][i].w; int t=f[u][r],j=(r+1)%k; if(t<w) t+=ceil((w-t)*1.0/k)*k; if(f[v][j]>t+1){ f[v][j]=t+1; q.push((node){v,j,f[v][j]}); } } } if(f[n][0]==f[0][0]) f[n][0]=-1; cout<<f[n][0]; }其他
1.移梵塔
/* 以 n=2 为例,执行流程如下; 1.move(2,A,B,C) 调用 move(1,A,C,B) move(1,A,C,B) 调用 move(0,A,B,C) ( 直接返回 ) 输出;1 A-> B( 将 1 个盘子从 A 移到 C ) move(1,,A,C,B)调用move(0,C,A,B)( 直接返回 ) 2.输出;2 A-> C( 将第 2 个盘子从 A 移到 C ) 3.move(2,A,B,C)调用move(1,B,A,C) move(1,B,A,C)调用move(0,B,A,C) */ #include<bits/stdc++.h> using namespace std; int num,n; void move(int n,char A,char B,char C){ if(n==0) return ; move(n-1,A,C,B); cout<<++num<<" "<<A<<"->"<<C<<endl; move(n-1,B,A,C); } main(){ cin>>n; move(n,'A','B','C'); } /* 基本情况:当 n=0 时,直接返回(递归终止条件) */2.信使
#include<bits/stdc++.h> using namespace std; const int N=150,INF=1e9; int n,m,a[N][N]; void floyd(){ for(int k=1;k<=n;k++){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ a[i][j]=min(a[i][j],a[i][k]+a[k][j]); } } } } main(){ memset(a,0x3f3f3f3f,sizeof a); cin>>n>>m; while(m--){ int u,v,z; cin>>u>>v>>z; a[u][v]=min(a[u][v],z); a[v][u]=min(a[v][u],z); } floyd(); int maxn=0; for(int i=2;i<=n;i++){ if(a[1][i]>0x3f3f3f3f/2){ cout<<-1; return 0;} if(a[1][i]>maxn) maxn=a[1][i]; } cout<<maxn; }3.大盗阿福
#include<bits/stdc++.h> using namespace std; const int N=100050; int n,m,dp[N][5],a[N]; main(){ cin>>n; while(n--){ cin>>m; for(int i=1;i<=m;i++) cin>>a[i]; for(int i=1;i<=m;i++){ dp[i][0]=max(dp[i-1][0],dp[i-1][1]); dp[i][1]=dp[i-1][0]+a[i]; } cout<<max(dp[m][0],dp[m][1])<<"\n"; } }4.鸡翅和鸭翅
#include<bits/stdc++.h> using namespace std; #define int long long int p,f,s,w,cnts,cntw,sum; main(){ freopen("food.in","r",stdin); freopen("food.out","w",stdout); //优化 cin/cout cin.tie(0);cout.tie(0); cin>>p>>f>>cnts>>cntw>>s>>w; if(s>w){ //把重量轻的放在前面 swap(s,w); swap(cnts,cntw); } for(int i=0;i*s<=p&&i<=cnts;i++){ int j=(p-i*s)/w; //计算第一个学生买的鸭腿数量 j=min(cntw,j); int k=cnts-i; //计算第二个学生买的鸡腿数量 k=min(k,f/s); int o=(f-k*s)/w; //计算第二个学生买的鸭腿数量 o=min(cntw-j,o); sum=max(sum,i+j+k+o); } cout<<sum; }5.四元组
//定义 s[i][j] 为前 i 个数中 j 有几个 //范围内 i 的情况数为 s[j-1][a[k]],l 的情况数为 s[k][a[j]] //接着 加法原理 + 乘法原理 #include<bits/stdc++.h> #define ll long long using namespace std; ll n,a[5005],s[5005][5005],sum; signed main(){ freopen("group.in","r",stdin); freopen("group.out","w",stdout); cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; for(int j=1;j<=n;j++){ s[i][j]=s[i-1][j]; if(j==a[i]) s[i][j]++; } } for(int j=1;j<=n;j++){ for(int k=j+1;k<=n;k++){ sum+=s[j-1][a[k]]*(s[n][a[j]]-s[k][a[j]]); } } cout<<sum; } //可以参考一下这个链接:https://oiclass.com/d/puji/p/P3671/solution/63137e4b1e3e23889836c07d其他知识点
优先队列
//定义:priority_queue<int,vector<int>,greater<int> > q; //用法: q.push(); //插入某个元素到队首 q.pop(); //弹出队首元素 q.top(); //访问队首元素 q.empty(); //队列为空(一般用于判断) q.size(); //访问队列元素个数并查集
//并查集模板 #include<bits/stdc++.h> using namespace std; #define int long long const int N=10000005; int n,m; int fa[N]; //扁平化操作 int findroot(int x){ if(fa[x]==x) return x; return fa[x]=findroot(fa[x]); } signed main(){ cin>>n>>m; for(int i=1;i<=n;i++) fa[i]=i; //输入并合并 for(int i=1;i<=m;i++){ int u,v,z; cin>>z>>u>>v; int fx=findroot(u); int fy=findroot(v); if(z==1){ if(fx!=fy){ fa[fx]=fy; } } else { if(fa[fx]==fa[fy]){ cout<<"Y\n"; } else cout<<"N\n"; } } return 0; }小游戏-1
#include<windows.h> #include<bits/stdc++.h> using namespace std; string xz; bool p,tz[41][10]; short sum; string dj[10]={"","普通","罕见","稀有","史诗","传奇","神话","究极","超级","唯一"}; short num[10]={0,1,3,9,27,81,243,729,2187,6561}; namespace flhb{ string hbname[41]={"","基本","尾刺","轻","石头","玻璃","蜂蜡","碎纸片","血刺","玫瑰","土","电","金币","魔法球","魔法刺","世界树之叶","叶子","魔法叶子","金盔","血祭","锯齿","齿轮"}; short lqtime[41]={0,2,10,1,4,1,30,1,6,4,5,1,1,4,0,512,1,1,60,0,0,2}; short hbsh[41]={0,10,100,13,15,15,2,1,100,5,10,15,5,0,250,0,13,13,0,0,0,50}; short nj[41]={0,10,2,5,45,1,0,1,2,5,10,100,15,10,2,10,12,12,243,0,10,2}; short starnum[41]={0,0,4,2,3,2,3,0,3,3,8,4,0,5,4,90,2,2,10,3,10,1}; int star[10]={0,0,0,0,0,20,500,15000,750000,0}; } namespace moster{ short dlexp[41]={0,1,1,1,1,1,1,1,1,1,1,1,1,1}; string dlname[41]={"","岩石","商人","资本家","蜜蜂","瓢虫","泥土","变异瓢虫","幼蚁","工蚁","泰坦","重组机","盲盒机","机器"}; int hpnum[10]={0,1,3,12,60,480,4320,43200,1296000,12960000}; int expnum[10]={0,1,2,10,60,480,3820,38200,528000,1280000}; short hp[41]={0,30,1,0,20,25,15,35,10,35,1,1,1,35}; short dlsh[41]={0,10,0,0,50,30,5,50,5,5,0,0,0,50}; short hj[41]={0,1,1,0,1,2,1,3,1,1,1,1,1,4}; short gg[41]={0,1,5,2,2,2,1,2,1,2,5,5,5,1};//1是被动,2是中立,3是敌对,4是召唤,5是NPC,6是友善 short dlstar[10]={0,0,0,0,0,10,20,40,160,640}; } using namespace flhb; using namespace moster; struct flower{ string ID; float hp,gamehp,gamemaxhp; short lv,maxmana,mana; int sxexp,exp,mark,star,gamestsh,stsh; bool xj; }fl; struct Moster{ string name; int hp,sh,exp,gamehp; short dltime,gg,star,hj; }dl[41][10]; struct Flower{ string name; int sh,nj,sum,zl,maxhp,gamenj,star,stsh; short lqtime,zwsh,maxmana,mana,sxmana; bool live,maxnj,xj,lq; }hb[41][10],cw[11],ccw[11],cccw; void print(){ for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j].sum>0){ cout<<hb[i][j].name; if(hb[i][j].sxmana)cout<<"\n魔力消耗:"<<hb[i][j].sxmana; if(hb[i][j].lqtime)cout<<"\n冷却时间:"<<hb[i][j].lqtime<<"秒"; if(hb[i][j].sh)cout<<"\n伤害:"<<hb[i][j].sh; if(hb[i][j].stsh)cout<<"\n身体伤害:+"<<hb[i][j].stsh; if(hb[i][j].nj)cout<<"\n耐久:"<<hb[i][j].nj; if(hb[i][j].zl)cout<<"\n治疗:"<<hb[i][j].zl; if(hb[i][j].maxhp)cout<<"\n花朵最大生命值:"<<hb[i][j].maxhp; if(hb[i][j].zwsh)cout<<"\n自我伤害:"<<hb[i][j].zwsh; if(hb[i][j].maxmana)cout<<"\n基础魔力上限:"<<hb[i][j].maxmana; if(hb[i][j].mana)cout<<"\n魔力:"<<hb[i][j].mana; if(i==18)cout<<"\n耐久上限:"<<hb[i][j].nj; if(i==19)cout<<"\n死亡后,召唤1只生物(超级)"; cout<<"\n数量:"<<hb[i][j].sum<<"\n\n"; } } } } void printdl(short a,short b){ cout<<dl[a][b].name<<"\n经验:"<<dl[a][b].exp<<"\n生命值:"<<dl[a][b].gamehp<<"\n伤害:"<<dl[a][b].sh<<"\n护甲:"<<dl[a][b].hj<<"\n\n"; } void printme(){ cout<<"用户名:"<<fl.ID<<"\n等级:"<<fl.lv<<"\n花朵最大生命值:"<<fl.gamemaxhp<<"\n花朵当前生命值:" <<fl.gamehp<<"\n身体伤害:"<<fl.gamestsh; if(fl.maxmana){ cout<<"\n魔力上限:"<<fl.maxmana<<"\n魔力:"<<fl.mana; } cout<<"\n\n"; } void printcw(short a){ cout<<"槽位"<<a<<":\n"; cout<<cw[a].name; if(cw[a].sxmana)cout<<"\n魔力消耗:"<<cw[a].sxmana; if(cw[a].lqtime)cout<<"\n冷却时间:"<<cw[a].lqtime<<"秒"; if(cw[a].sh)cout<<"\n伤害:"<<cw[a].sh; if(cw[a].stsh)cout<<"\n身体伤害:+"<<cw[a].stsh; if(cw[a].nj)cout<<"\n耐久:"<<cw[a].nj; if(cw[a].zl)cout<<"\n治疗:"<<cw[a].zl; if(cw[a].maxhp)cout<<"\n花朵最大生命值:"<<cw[a].maxhp; if(cw[a].zwsh)cout<<"\n自我伤害:"<<cw[a].zwsh; if(cw[a].maxmana)cout<<"\n基础魔力上限:"<<cw[a].maxmana; if(cw[a].mana)cout<<"\n魔力:"<<cw[a].mana; if(cw[a].maxnj)cout<<"\n耐久上限:"<<cw[a].nj; if(cw[a].xj)cout<<"\n死亡后,召唤1只生物(超级)"; cout<<"\n\n"; } void _(){ for(short i=1;i<121;i++)cout<<'_'; cout<<endl; } void flush(){ srand(time(0)); short s=0; while(fl.exp>=fl.sxexp){ fl.exp-=fl.sxexp; s++; fl.sxexp=7*fl.sxexp/6; fl.stsh=10*fl.stsh/9; fl.hp=11*fl.hp/10; } fl.lv+=s; if(s){ system("cls"); system("color 2f"); cout<<"你升了"<<s<<"级,生命:"<<fl.hp<<",身体伤害:"<<fl.stsh<<",升级所需经验:"<<fl.sxexp; Sleep(rand()%3333+1000); } } void shezhi(){ srand(time(0)); hb[20][1].stsh=27; hb[16][1].zl=1; hb[14][1].sxmana=27; hb[13][1].maxmana=hb[17][1].maxmana=30; hb[13][1].mana=5; hb[17][1].mana=2; hb[10][1].maxhp=50; hb[9][1].zl=8; hb[8][1].zwsh=4; hb[6][3].nj=12000; for(short i=1;i<41;i++){ hb[i][1].sh=hbsh[i]; hb[i][1].nj=nj[i]; } for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j-1].sh&&j>1)hb[i][j].sh=hb[i][j-1].sh*3; hb[i][j].name=hbname[i]+'('+dj[j]+')'; if(hb[i][j-1].nj&&j>1)hb[i][j].nj=hb[i][j-1].nj*3; if(hb[i][j-1].zl&&j>1)hb[i][j].zl=hb[i][j-1].zl*3; if(i!=15||(i==15&&j<2))hb[i][j].lqtime=lqtime[i]; else hb[i][j].lqtime=hb[i][j-1].lqtime/2; if(hb[i][j-1].maxhp&&j>1)hb[i][j].maxhp=hb[i][j-1].maxhp*3; if(hb[i][j-1].zwsh&&j>1)hb[i][j].zwsh=hb[i][j-1].zwsh*3; if(hb[i][j-1].maxmana&&j>1)hb[i][j].maxmana=hb[i][j-1].maxmana*2; if(hb[i][j-1].mana&&j>1)hb[i][j].mana=hb[i][j-1].mana*2; if(hb[i][j-1].sxmana&&j>1)hb[i][j].sxmana=hb[i][j-1].sxmana*2; hb[15][j].live=hb[18][j].maxnj=hb[19][j].xj=hb[21][j].lq=1; if(hb[i][j-1].stsh&&j>1)hb[i][j].stsh=hb[i][j-1].stsh*3; } } } void ID(){ fl.lv=1; fl.sxexp=30; fl.hp=100; fl.stsh=10; sum=5; system("color 2f"); cout<<setw(65)<<"欢迎游玩flower.io!\n"; _(); cout<<"请输入ID:"; cin>>fl.ID; cout<<"\n注册成功!送你5个"<<hb[1][1].name<<",送你1个"<<hb[9][1].name; Sleep(500); hb[1][1].sum=5; hb[9][1].sum=1; } void shezhidl(){ for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ dl[i][j].exp=dlexp[i]*expnum[j]; dl[i][j].name=dlname[i]+'('+dj[j]+')'; dl[i][j].hj=hj[i]*num[j]; dl[i][j].hp=hp[i]*hpnum[j]; dl[i][j].sh=dlsh[i]*num[j]; dl[i][j].gg=gg[i]; dl[2][j].exp=dl[3][j].exp=dl[10][j].exp=dl[11][j].exp=dl[12][j].exp=1; } } } void shop(){ bool a[41][10]; pp:; memset(tz,0,sizeof(tz)); memset(a,0,sizeof(a)); srand(time(0)); system("cls"); system("color 2f"); cout<<setw(65)<<"flower商店界面\n"; _(); cout<<"用户名:"<<fl.ID<<"\n星星数量:"<<fl.star; cout<<"\n\n商店:\n\n"; for(int i=1;i<rand()%8+5;i++){ short x=rand()%21+1,y=rand()%4+5; while(a[x][y]||!starnum[x]||(x==19&&y<8))x=rand()%20+1,y=rand()%4+5; a[x][y]=1; cout<<hb[x][y].name; if(hb[x][y].sxmana)cout<<"\n魔力消耗:"<<hb[x][y].sxmana; if(hb[x][y].lqtime)cout<<"\n冷却时间:"<<hb[x][y].lqtime<<"秒"; if(hb[x][y].sh)cout<<"\n伤害:"<<hb[x][y].sh; if(hb[x][y].stsh)cout<<"\n身体伤害:+"<<hb[x][y].stsh; if(hb[x][y].nj)cout<<"\n耐久:"<<hb[x][y].nj; if(hb[x][y].zl)cout<<"\n治疗:"<<hb[x][y].zl; if(hb[x][y].maxhp)cout<<"\n花朵最大生命值:"<<hb[x][y].maxhp; if(hb[x][y].zwsh)cout<<"\n自我伤害:"<<hb[x][y].zwsh; if(hb[x][y].maxmana)cout<<"\n基础魔力上限:"<<hb[x][y].maxmana; if(hb[x][y].mana)cout<<"\n魔力:"<<hb[x][y].mana; if(x==18)cout<<"\n耐久上限:"<<hb[x][y].nj; if(hb[x][y].xj)cout<<"\n死亡后,召唤1只生物(超级)"; cout<<"\n所需星星数:"<<starnum[x]*star[y]<<"\n\n"; } cout<<"挑战:\n\n"; for(int i=1;i<5;i++){ short x=rand()%13+1,y=rand()%5+5; while(x==2||x==3||x==10||x==11||x==12||tz[x][y])x=rand()%12+1,y=rand()%5+5; cout<<dl[x][y].name<<"\n经验:"<<dl[x][y].exp<<"\n生命值:"<<dl[x][y].hp<<"\n伤害:"<<dl[x][y].sh<<"\n护甲:"<<dl[x][y].hj<<"\n星星数:"<<dlstar[y]<<"\n\n"; tz[x][y]=1; } cout<<"\n你要购买什么花瓣?或按0键退出\n"; string name; re:; cin>>name; if(name=="0")return; for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j].name==name){ if(fl.star<starnum[i]*star[j]){ cout<<"星星不够!\n"; goto re; }if(!a[i][j]){ cout<<"不能购买!\n"; goto re; }else{ fl.star-=starnum[i]*star[j]; hb[i][j].sum++; } cout<<"你获得了1个"<<hb[i][j].name; goto r; } } } cout<<"没有这个花瓣!\n"; goto re; r:; Sleep(500); goto pp; } void hcjm(){ short s; string name; srand(time(0)); pp:; system("cls"); system("color 2f"); cout<<setw(65)<<"flower合成界面\n"; _(); print(); cout<<"需要至少5个花瓣合成,合成罕见、稀有、史诗、传奇、神话、究极、超级的概率是64%、32%、16%、8%、4%、2%、1%\n你要用什么花瓣合成?或按0键退出\n"; re:; cin>>name; if(name=="0")return; short dd=0,sq=0; for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j].name==name){ if(hb[i][j].sum<5){ cout<<"花瓣不够!\n"; goto re; }if(j>7||(i<2&&j<2)){ cout<<"不能合成!\n"; goto re; }else{ while(hb[i][j].sum>=5){ short x=rand()%200+1; if(x<=pow(2,8-j)){ hb[i][j].sum-=5; hb[i][j+1].sum++; dd++; }else{ s=rand()%4+1; hb[i][j].sum-=s; sq+=s; } } } cout<<"你合成了"<<dd<<"个"<<hb[i][j+1].name<<",损失了"<<sq<<"个"<<hb[i][j].name; goto r; } } } cout<<"没有这个花瓣!\n"; goto re; r:; Sleep(500); goto pp; } void ballgame(){ string name; srand(time(0)); pp:; system("cls"); system("color 2f"); cout<<setw(65)<<"flower弹珠游戏\n"; _(); print(); cout<<"需要至少1个非唯一花瓣游玩,有概率获得1、2、3、5、20、500个花瓣\n你要用什么花瓣进行弹珠游戏?或按0键退出\n"; re:; cin>>name; if(name=="0")return; short dd=0,sq=0; for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j].name==name){ if(hb[i][j].sum<1){ cout<<"花瓣不够!\n"; goto re; }if(j>8){ cout<<"不能游玩!\n"; goto re; }else{ for(short i1=1;i1<=hb[i][j].sum;i1++){ hb[i][j].sum--; int x=rand()%10000+1; if(x<2201){ sq++; dl[3][1].hp+=hb[i][j].nj; dl[3][1].sh+=hb[i][j].sh; }if(x>2200&&x<9001){ dd++; }if(x>9000&&x<9801){ dd+=2; }if(x>9800&&x<9901){ dd+=3; }if(x>9900&&x<9991){ dd+=5; }if(x>9990&&x<10000){ dd+=20; }if(x>9999){ dd+=500; } } hb[i][j].sum+=dd; } cout<<"你获得了"<<dd<<"个"<<hb[i][j].name<<",损失了"<<sq<<"个"<<hb[i][j].name; goto r; } } } cout<<"没有这个花瓣!\n"; goto re; r:; Sleep(500); goto pp; } void gamebegin(){ string a,name; tt:; system("cls"); system("color 2f"); cout<<setw(65)<<"flower游戏界面\n"; _(); print(); if(!p){ cout<<"你有10个槽位,你要装备哪些花瓣?按0键结束配装\n"; for(short k=0;k<11;k++){ ss:; cin>>name; if(name=="0")break; for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j].name==name){ if(hb[i][j].sum<1){ cout<<"花瓣不够!\n"; goto ss; }else{ if(k<10){ hb[i][j].sum--; cw[++k]=hb[i][j]; system("cls"); system("color 2f"); cout<<setw(65)<<"flower游戏界面\n"; _(); print(); for(int i=1;i<11;i++){ if(cw[i].name!="")printcw(i); } cout<<"你有10个槽位,你要装备哪些花瓣?按0键结束配装\n"; }else{ p=1; goto aa; } goto ss; } } } } cout<<"没有这个花瓣!\n"; Sleep(5000); goto tt; } p=1; } aa:; system("cls"); system("color 2f"); cout<<setw(65)<<"flower游戏界面\n"; _(); print(); for(short i=1;i<11;i++){ if(cw[i].name!="")printcw(i); } cout<<"请选择:\n 1.保存配装\n 2.取消配装\n"; cin>>a; while(a!="1"&&a!="2"){ cout<<"请重新输入!\n"; cin>>a; } if(a=="1")return; p=0; for(short i1=1;i1<11;i1++){ for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j].name==cw[i1].name){ hb[i][j].sum++; } } } cw[i1]=cccw; } goto tt; } void game(){ string a; for(short i=1;i<11;i++)cw[i].gamenj=cw[i].nj; system("cls"); system("color 2f"); cout<<setw(65)<<"flower游戏界面\n"; _(); cout<<"请选择:\n 1.开始游戏\n 2.退出游戏\n"; cin>>a; while(a!="1"&&a!="2"){ cout<<"请重新输入!\n"; cin>>a; } if(a=="2")return; else{ fl.maxmana=fl.mark=fl.gamemaxhp=0; for(short i=1;i<11;i++){ fl.gamemaxhp=max(fl.gamemaxhp,(float)cw[i].maxhp); fl.maxmana=max(fl.maxmana,cw[i].maxmana); fl.gamestsh=max(fl.gamestsh,fl.stsh+cw[i].stsh); } fl.gamemaxhp=max(fl.hp,fl.gamemaxhp); fl.gamehp=fl.gamemaxhp; aa:; short a=rand()%3+1; fl.gamemaxhp=0; fl.gamemaxhp=max(fl.hp,fl.gamemaxhp); for(short i=1;i<11;i++){ fl.gamemaxhp=max(fl.gamemaxhp,(float)cw[i].maxhp); fl.maxmana=max(fl.maxmana,cw[i].maxmana); fl.gamestsh=max(fl.gamestsh,fl.stsh+cw[i].stsh); } system("cls"); system("color 2f"); cout<<setw(65)<<"flower游戏界面\n"; _(); srand(time(0)); if(a==2){ short x1,y1; if(fl.lv<2)x1=rand()%4+2,y1=1; if(fl.lv>1&&fl.lv<6)x1=rand()%4+2,y1=rand()%3+1; if(fl.lv>5&&fl.lv<21)x1=rand()%9+2,y1=rand()%2+3; if(fl.lv>20)x1=rand()%9+2,y1=rand()%3+3; for(short i=1;i<11;i++){ if(cw[i].name==""&&cw[i].nj<1){ cw[i]=hb[x1][y1]; goto ww; } } hb[x1][y1].sum++; ww:; cout<<"\n你获得了1个"<<hb[x1][y1].name; Sleep(500); goto aa; } short x=rand()%13+1,y; if(fl.lv<2)y=1; if(fl.lv>1&&fl.lv<6){ short x=rand()%10+1; if(x<7)y=1; if(x>6&&x<10)y=2; if(x>9)y=3; }if(fl.lv>5&&fl.lv<11){ short x=rand()%100+1; if(x<41)y=1; if(x>40&&x<71)y=2; if(x>70&&x<93)y=3; if(x>92)y=4; }if(fl.lv>10&&fl.lv<21){ short x=rand()%100+1; if(x<41)y=rand()%2+1; if(x>40&&x<71)y=3; if(x>70&&x<93)y=4; if(x>92)y=5; } if(fl.lv>20&&fl.lv<51){ short x=rand()%100+1; if(x<41)y=rand()%3+1; if(x>40&&x<71)y=4; if(x>70&&x<93)y=5; if(x>92)y=rand()%2+6; } if(fl.lv>50){ short x=rand()%100+1; if(x<41)y=rand()%4+1; if(x>40&&x<71)y=5; if(x>70&&x<93)y=6; if(x>92)y=rand()%3+7; } if(fl.xj){ y=8; while(x==3)x=rand()%12+1; fl.xj=0; } if(x==3)dl[3][y]=dl[3][1]; for(short i=1;i<11;i++){ if(cw[i].xj){ cw[i]=cccw; fl.xj=1; cout<<"你死了\n"; Sleep(1000); short x=0; system("cls"); system("color 2f"); if(fl.mark>30&&fl.mark<100)x=2; if(fl.mark>99&&fl.mark<1000)x=3; if(fl.mark>999&&fl.mark<5000)x=4; if(fl.mark>4999&&fl.mark<200000)x=5; if(fl.mark>199999)x=6; hb[1][x].sum++; cout<<"游戏结束!"; if(x)cout<<"你获得了1个"<<hb[1][x].name; Sleep(250); return; } } dl[x][y].gamehp=dl[x][y].hp; printdl(x,y); printme(); for(short i=1;i<11;i++){ if(cw[i].name>"")printcw(i); } if(dl[x][y].gg<3){ cout<<"请选择:\n 1.开始攻击\n 2.取消攻击\n 3.退出界面\n"; int lq[11]; string a; cin>>a; while(a!="1"&&a!="2"&&a!="3"){ cout<<"请重新输入!\n"; cin>>a; } if(a=="2")goto aa; if(a=="3"){ aaa:; short x=0; system("cls"); system("color 2f"); if(fl.mark>30&&fl.mark<100)x=2; if(fl.mark>99&&fl.mark<1000)x=3; if(fl.mark>999&&fl.mark<5000)x=4; if(fl.mark>4999&&fl.mark<200000)x=5; if(fl.mark>199999)x=6; hb[1][x].sum++; cout<<"游戏结束!"; if(x)cout<<"你获得了1个"<<hb[1][x].name; Sleep(rand()%3000+1234); return; } while(dl[x][y].gamehp>0){ dd:; for(short i=1;i<11;i++){ if(cw[i].nj&&cw[i].name==""&&time(0)-lq[i]>=cw[i].lqtime){ if(cw[i].sxmana&&fl.mana>=cw[i].sxmana){ fl.mana-=cw[i].sxmana; cout<<"你消耗了"<<cw[i].sxmana<<"点魔力\n"; Sleep(500); goto out; }if(cw[i].sxmana&&fl.mana<cw[i].sxmana)continue; out:; cw[i]=ccw[i]; ccw[i]=cccw; cw[i].gamenj=cw[i].nj; for(short j=1;j<11;j++){ if(cw[j].maxnj)cw[i].gamenj=max(cw[i].gamenj,cw[j].nj); } if(cw[i].zwsh){ fl.gamehp-=cw[i].zwsh; cout<<"你受到了"<<cw[i].zwsh<<"点伤害\n"; Sleep(500); short s=0; for(short i=1;i<11;i++){ if(cw[i].name>""&&cw[i].zl){ if(fl.gamehp+cw[i].zl>fl.gamemaxhp){ s+=fl.gamemaxhp-fl.gamehp; fl.gamehp=fl.gamemaxhp; }else{ fl.gamehp+=cw[i].zl; s+=cw[i].zl; } cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); } } cout<<"你回复了"<<s<<"点体力\n"; Sleep(500); if(fl.gamehp<=0){ cout<<"你死了\n"; Sleep(1000); for(short i=1;i<11;i++){ if(cw[i].name>""&&cw[i].live){ fl.gamehp=fl.gamemaxhp*2/10; cout<<"你使用了"<<cw[i].name<<",将血量回复至20%\n"; cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); Sleep(500); goto bbb; } } goto aaa; } } if(fl.mana<fl.maxmana){ short s=0; for(int i=1;i<11;i++){ if(cw[i].name>""&&cw[i].mana){ if(fl.mana+cw[i].mana>fl.maxmana){ s+=fl.maxmana-fl.mana; fl.mana=fl.maxmana; }else{ s+=cw[i].mana; fl.mana+=cw[i].mana; } cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); } } cout<<"你增加了"<<s<<"点魔力\n"; Sleep(500); } } } int s; system("cls"); system("color 2f"); cout<<setw(65)<<"flower游戏界面\n"; _(); printdl(x,y); printme(); for(short i=1;i<11;i++){ if(cw[i].name>"")printcw(i); } cout<<"你要使用第几个槽位的花瓣攻击?按0取消,按11进行碰撞\n"; cin>>a; if(a=="0")goto dd; if(a=="11")goto eee; while((a!="1"&&a!="2"&&a!="3"&&a!="4"&&a!="5"&&a!="6"&&a!="7"&&a!="8"&&a!="9"&&a!="10")||(a!="10"&&cw[a[0]-'0'].name==""||(a=="10"&&cw[10].name==""))){ cout<<"请重新输入!\n"; cin>>a; if(a=="0")goto dd; if(a=="11")goto eee; } if(a!="10"&&a!="11"){ if(cw[a[0]-'0'].sh>dl[x][y].hj)s=cw[a[0]-'0'].sh-dl[x][y].hj; else s=0; dl[x][y].gamehp-=s; cw[a[0]-'0'].gamenj-=dl[x][y].sh; if(cw[a[0]-'0'].gamenj<=0){ ccw[a[0]-'0']=cw[a[0]-'0']; cw[a[0]-'0'].name=""; lq[a[0]-'0']=time(0); if(cw[a[0]-'0'].lq){ for(short i=1;i<11;i++){ if(cw[i].name>""){ cw[i].name=""; lq[i]=time(0); cw[i].gamenj=0; } } } } cout<<dl[x][y].name<<"受到了"<<s<<"点伤害\n"; Sleep(500); s=0; if(fl.gamehp<fl.gamemaxhp){ for(short i=1;i<11;i++){ if(cw[i].name>""&&cw[i].zl){ if(fl.gamehp+cw[i].zl>fl.gamemaxhp){ s+=fl.gamemaxhp-fl.gamehp; fl.gamehp=fl.gamemaxhp; }else{ fl.gamehp+=cw[i].zl; s+=cw[i].zl; } cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); } } cout<<"你回复了"<<s<<"点体力\n"; Sleep(500); if(fl.gamehp<=0){ cout<<"你死了\n"; Sleep(1000); for(short i=1;i<11;i++){ if(cw[i].name>""&&cw[i].live){ fl.gamehp=fl.gamemaxhp*2/10; cout<<"你使用了"<<cw[i].name<<",将血量回复至20%\n"; cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); Sleep(500); goto bbb; } } goto aaa; } } if(fl.mana<fl.maxmana){ short s=0; for(int i=1;i<11;i++){ if(cw[i].name>""&&cw[i].mana){ if(fl.mana+cw[i].mana>fl.maxmana){ s+=fl.maxmana-fl.mana; fl.mana=fl.maxmana; }else{ s+=cw[i].mana; fl.mana+=cw[i].mana; } cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); } } cout<<"你增加了"<<s<<"点魔力\n"; Sleep(500); } }if(a=="10"){ if(cw[10].sh>dl[x][y].hj)s=cw[10].sh-dl[x][y].hj; else s=0; cw[10].gamenj-=dl[x][y].sh; if(cw[10].gamenj<=0&&cw[10].nj){ ccw[10]=cw[10]; cw[10].name=""; lq[10]=time(0); if(cw[10].lq){ for(short i=1;i<11;i++){ if(cw[i].name>""){ cw[i].name=""; lq[i]=time(0); cw[i].gamenj=0; } } } } cout<<dl[x][y].name<<"受到了"<<s<<"点伤害\n"; dl[x][y].gamehp-=s; Sleep(500); s=0; if(fl.gamehp<fl.gamemaxhp){ for(short i=1;i<11;i++){ if(cw[i].name>""&&cw[i].zl){ if(fl.gamehp+cw[i].zl>fl.gamemaxhp){ s+=fl.gamemaxhp-fl.gamehp; fl.gamehp=fl.gamemaxhp; }else{ fl.gamehp+=cw[i].zl; s+=cw[i].zl; } cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); } } cout<<"你回复了"<<s<<"点体力\n"; Sleep(500); if(fl.gamehp<=0){ cout<<"你死了"; Sleep(1000); for(short i=1;i<11;i++){ if(cw[i].name>""&&cw[i].live){ fl.gamehp=fl.gamemaxhp*2/10; cout<<"你使用了"<<cw[i].name<<",将血量回复至20%\n"; cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); Sleep(500); goto bbb; } } goto aaa; } } if(fl.mana<fl.maxmana){ short s=0; for(int i=1;i<11;i++){ if(cw[i].name>""&&cw[i].mana){ if(fl.mana+cw[i].mana>fl.maxmana){ s+=fl.maxmana-fl.mana; fl.mana=fl.maxmana; }else{ s+=cw[i].mana; fl.mana+=cw[i].mana; } cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); } } cout<<"你增加了"<<s<<"点魔力\n"; Sleep(500); } }if(a=="11"){ eee:; fl.gamehp-=dl[x][y].sh; int a=dl[x][y].sh,b; if(dl[x][y].hj<fl.gamestsh)b=fl.gamestsh-dl[x][y].hj; else b=0; cout<<"你受到"<<a<<"点伤害,"<<dl[x][y].name<<"受到"<<b<<"点伤害\n"; dl[x][y].gamehp-=b; Sleep(500); short s=0; for(short i=1;i<11;i++){ if(cw[i].name>""&&cw[i].zl){ if(fl.gamehp+cw[i].zl>fl.gamemaxhp){ s+=fl.gamemaxhp-fl.gamehp; fl.gamehp=fl.gamemaxhp; }else{ fl.gamehp+=cw[i].zl; s+=cw[i].zl; } cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); } } cout<<"你回复了"<<s<<"点体力\n"; Sleep(500); if(fl.gamehp<=0){ cout<<"你死了\n"; Sleep(1000); for(short i=1;i<11;i++){ if(cw[i].name>""&&cw[i].live){ fl.gamehp=fl.gamemaxhp*2/10; cout<<"你使用了"<<cw[i].name<<",将血量回复至20%\n"; cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); Sleep(500); goto bbb; } } goto aaa; } if(fl.mana<fl.maxmana){ short s=0; for(int i=1;i<11;i++){ if(cw[i].name>""&&cw[i].mana){ if(fl.mana+cw[i].mana>fl.maxmana){ s+=fl.maxmana-fl.mana; fl.mana=fl.maxmana; }else{ s+=cw[i].mana; fl.mana+=cw[i].mana; } cw[i].gamenj=0; ccw[i]=cw[i]; cw[i].name=""; lq[i]=time(0); } } cout<<"你增加了"<<s<<"点魔力\n"; Sleep(500); } } bbb:; } cout<<"你击败了"<<dl[x][y].name; short y1=0,x1=0,x2=0,y2=0,x3=0,y3=0; if(x==1){ x1=4; x2=6; x3=5; if(y==1){ short x=rand()%2+1; if(x<2)y1=1; else y1=2; y3=1; }if(y==2){ short x=rand()%10+1; if(x<3)y1=1; else y1=2; y3=1; }if(y==3){ short x=rand()%10+1; if(x<7)y1=2; else y1=3; if(x>3)y2=3; if(x<7)y3=2; else y3=3; }if(y==4){ short x=rand()%10+1; if(x<8)y1=3; else y1=4; if(x<9)y2=3; else y2=4; y3=3; }if(y==5){ short x=rand()%100+1; if(x<11)y1=3; if(x>10&&x<95)y1=4; if(x>94)y1=5; if(x<6)y2=3; if(x>5&&x<90)y2=4; if(x>89)y2=5; if(x<4)y3=3; if(x>3&&x<93)y3=4; if(x>92)y3=5; }if(y==6){ short x=rand()%100+1; if(x<41)y1=4; if(x>=41&&x<98)y1=5; if(x>97)y1=6; if(x<50)y2=4; if(x>49&&x<97)y2=5; if(x>96)y2=6; if(x<6)y3=4; if(x>5&&x<99)y3=5; if(x>98)y3=6; }if(y==7){ short x=rand()%100+1; if(x<92)y1=5; else y1=6; if(x<54)y2=5; else y2=6; if(x<7)y3=5; else y3=6; }if(y==8){ short x=rand()%100+1; if(x<86)y1=6; else y1=7; if(x<76)y2=6; else y2=7; if(x<70)y3=6; else y3=7; }if(y==9){ short x=rand()%100+1; if(x<55)y1=6; else y1=7; if(x<51)y2=6; else y2=7; if(x<49)y3=6; else y3=7; } }if(x==3){ x1=12; y1=rand()%4+1; }if(x==4){ x1=2; x2=8; if(fl.maxmana)x1=x2=14; if(y==1)y1=y2=1; if(y==2){ short x=rand()%10+1; if(x<5)y1=y2=1; else y1=y2=2; }if(y==3){ short x=rand()%10+1; if(x<5)y1=y2=2; else y1=y2=3; }if(y==4){ short x=rand()%10+1; if(x<8)y1=y2=3; else y1=y2=4; }if(y==5){ short x=rand()%100+1; if(x<12)y1=y2=3; if(x>11&&x<93)y1=y2=4; if(x>92)y1=y2=5; }if(y==6){ short x=rand()%100+1; if(x<41)y1=y2=4; if(x>=41&&x<98)y1=y2=5; if(x>97)y1=y2=6; }if(y==7){ short x=rand()%100+1; if(x<90)y1=y2=5; else y1=y2=6; }if(y==8){ short x=rand()%100+1; if(x<89)y1=y2=6; else y1=y2=7; }if(y==9){ short x=rand()%100+1; if(x<57)y1=y2=6; else y1=y2=7; } }if(x==5){ x1=3; x2=9; x3=16; if(fl.maxmana)x3=17; if(y==1){ y1=1; y2=1; }if(y==2){ y1=2; y2=1; y3=2; }if(y==3){ short x=rand()%10+1; if(x<3)y1=2; else y1=3; if(x<5)y2=y3=2; else y2=y3=3; }if(y==4){ short x=rand()%10+1; if(x<7)y1=3; else y1=4; if(x<8)y2=y3=3; else y2=y3=4; }if(y==5){ short x=rand()%100+1; if(x<90)y1=4; else y1=5; if(x<95)y2=y3=4; else y2=y3=5; }if(y==6){ short x=rand()%1000+1; if(x<992)y1=5; else y1=6; if(x<997)y2=y3=5; else y2=y3=6; }if(y==7){ short x=rand()%1000+1; if(x<992)y1=6; else y1=7; if(x<333)y2=y3=5; else y2=y3=6; }if(y==8){ short x=rand()%100+1; if(x<88)y1=6; else y1=7; if(x<92)y2=y3=6; else y2=y3=7; }if(y==9){ short x=rand()%100+1; if(x<43)y1=6; else y1=7; if(x<44)y2=y3=6; else y2=y3=7; } }if(x==6){ x1=10; if(y<2){ short a=rand()%10+1; if(a<5)y1=1; }if(y>1&&y<8)y1=y-1; if(y>7)y1=y-2; }if(x==7){ x1=3; x2=13; x3=15; if(y==1)y1=1; if(y==2)y1=2; if(y==3){ short x=rand()%10+1; if(x<3)y1=2; else y1=3; if(x<4)y2=1; if(x>3&&x<7)y2=2; if(x>6)y2=3; }if(y==4){ short x=rand()%10+1; if(x<7)y1=3; else y1=4; if(x<9)y2=2; else y2=3; }if(y==5){ short x=rand()%100+1; if(x<90)y1=4; else y1=5; if(x<98)y2=4; else y2=5; if(x<5)y3=1; }if(y==6){ short x=rand()%1000+1; if(x<992)y1=5; else y1=6; if(x<997)y2=5; else y2=6; if(x<20)y3=1; if(x>19&&x<25)y3=2; }if(y==7){ short x=rand()%1000+1; if(x<992)y1=6; else y1=7; if(x<666)y2=5; else y2=6; if(x<100)y3=1; if(x>99&&x<666)y3=2; if(x>665&&x<777)y3=3; }if(y==8){ short x=rand()%100+1; if(x<88)y1=6; else y1=7; if(x<97)y2=6; else y2=7; if(x<23)y3=2; if(x>22&&x<95)y3=3; if(x>94)y3=4; }if(y==9){ short x=rand()%100+1; if(x<43)y1=6; else y1=7; if(x<89)y2=6; else y2=7; if(x<92)y3=3; else y3=4; } }if(x==8){ x1=7; if(y<9)y1=y; else y1=8; }if(x==9){ x1=3; x2=5; if(y==1)y1=1; if(y==2)y2=2; if(y==3){ short x=rand()%10+1; if(x<3)y1=3; if(x<4)y2=3; }if(y==4){ short x=rand()%10+1; if(x<7)y1=3; else y1=4; if(x<9)y2=2; else y2=3; }if(y==5){ short x=rand()%100+1; if(x<90)y1=4; else y1=5; if(x<98)y2=4; else y2=5; }if(y==6){ short x=rand()%1000+1; if(x<666)y1=5; else y1=6; if(x<622)y2=5; else y2=6; }if(y==7){ short x=rand()%1000+1; if(x<666)y1=6; else y1=7; if(x<677)y2=5; else y2=6; }if(y==8){ short x=rand()%100+1; if(x<66)y1=6; else y1=7; if(x<67)y2=6; else y2=7; }if(y==9){ short x=rand()%100+1; if(x<21)y1=6; else y1=7; if(x<32)y2=6; else y2=7; } }if(x==13){ x1=21; x2=20; x3=18; if(y<4){ short x=rand()%10+1; y1=1; if(x<3)y2=1; }if(y>3&&y<8){ short x=rand()%10+1; y1=4; if(x<3)y2=4; else y2=1; if(x<5)y3=2; else y3=1; }if(y>7){ short x=rand()%100+1; if(x<20)y2=7; else y2=4; if(x<2)y2=7; else y2=4; if(x<96)y3=5; else y3=1; } } if(x1>0&&y1>0){ for(short i=1;i<11;i++){ if(cw[i].name==""&&cw[i].nj<1){ cw[i]=hb[x1][y1]; goto w; } } hb[x1][y1].sum++; w:; cout<<"\n你获得了1个"<<hb[x1][y1].name; } if(x2>0&&y2>0){ for(short i=1;i<11;i++){ if(cw[i].name==""&&cw[i].nj<1){ cw[i]=hb[x2][y2]; goto w2; } } hb[x2][y2].sum++; w2:; cout<<"\n你获得了1个"<<hb[x2][y2].name; } if(x3>0&&y3>0){ for(short i=1;i<11;i++){ if(cw[i].name==""&&cw[i].nj<1){ cw[i]=hb[x3][y3]; goto w3; } } hb[x3][y3].sum++; w3:; cout<<"\n你获得了1个"<<hb[x3][y3].name; } if(tz[x][y]){ cout<<"\n你获得了"<<dlstar[y]<<"个星星"; fl.star+=dlstar[y]; } Sleep(1000); fl.exp+=dl[x][y].exp; fl.mark+=dl[x][y].exp/2; flush(); goto aa; }if(dl[x][y].gg==5){ Sleep(2000); system("cls"); system("color 2f"); if(x==2){ string name; cout<<setw(65)<<"flower兑换界面\n"; _(); print(); cout<<"你可以用1个非唯一花瓣兑换金币\n你要用什么花瓣兑换?或按0键退出\n"; re:; cin>>name; if(name=="0")goto aa;; for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j].name==name){ if(hb[i][j].sum<1){ cout<<"花瓣不够!\n"; goto re; }if(j>8||i<2){ cout<<"不能兑换!\n"; goto re; }else{ hb[i][j].sum--; hb[12][j].sum++; } cout<<"你获得了1个"<<hb[12][j].name; goto aaaa; } } } cout<<"没有这个花瓣!\n"; goto re; }if(x==10){ string name; cout<<setw(65)<<"flower锻造界面\n"; _(); print(); cout<<"你可以用"<<sum<<"个超级花瓣锻造唯一花瓣\n你要用什么花瓣锻造?或按0键退出\n"; rrr:; cin>>name; if(name=="0")goto aa; for(int i=1;i<41;i++){ if(name==hb[i][8].name){ if(hb[i][8].sum<sum){ cout<<"花瓣不够!\n"; goto rrr; }else{ if(hb[i][9].sum||i==19){ cout<<"不能锻造!\n"; goto rrr; } hb[i][8].sum-=sum; hb[i][9].sum=1; cout<<"你锻造了1个"<<hb[i][9].name; sum++; goto aaaa; } } } cout<<"不能锻造!\n"; goto rrr; }if(x==11){ string a; srand(time(0)); cout<<setw(65)<<"flower重组界面\n"; _(); print(); short x=rand()%8+1; cout<<"请选择:\n 1.使用10000个"<<hb[16][x].name<<"重组1个"<<hb[15][x].name<<"\n 2.使用1000个"<<hb[12][x].name<<"重组1个"<<hb[18][x].name<<"\n 3.使用2个"<<hb[8][x].name<<"重组1个"<<hb[2][x].name<<"\n 4.使用1个"<<hb[6][x].name<<"重组1个"<<hb[4][x].name<<"和1个"<<hb[5][x].name<<"\n 5.使用100个"<<hb[7][x].name<<"重组1个"<<hb[3][x].name<<"\n 6.退出界面\n"; abc:; cin>>a; while(a!="1"&&a!="2"&&a!="3"&&a!="4"&&a!="5"&&a!="6"){ cout<<"请重新输入!\n"; cin>>a; } if(a=="6")goto aa; if(a=="1"){ if(hb[16][x].sum<10000){ cout<<"花瓣不够!\n"; goto abc; }else{ hb[16][x].sum-=10000; hb[15][x].sum++; cout<<"你重组了1个"<<hb[15][x].name; } }if(a=="2"){ if(hb[12][x].sum<1000){ cout<<"花瓣不够!\n"; goto abc; }else{ hb[12][x].sum-=1000; hb[18][x].sum++; cout<<"你重组了1个"<<hb[2][x].name; } }if(a=="3"){ if(hb[8][x].sum<2){ cout<<"花瓣不够!\n"; goto abc; }else{ hb[8][x].sum-=2; hb[2][x].sum++; cout<<"你重组了1个"<<hb[2][x].name; } }if(a=="4"){ if(hb[6][x].sum<1){ cout<<"花瓣不够!\n"; goto abc; }else{ hb[6][x].sum--; hb[4][x].sum++; hb[5][x].sum++; cout<<"你重组了1个"<<hb[4][x].name<<"和1个"<<hb[5][x].name; } }if(a=="5"){ if(hb[7][x].sum<100){ cout<<"花瓣不够!\n"; goto abc; }else{ hb[7][x].sum-=100; hb[3][x].sum++; cout<<"你重组了1个"<<hb[3][x].name; } goto aaaa; } }if(x==12){ string a; cout<<setw(65)<<"flower盲盒界面\n"; _(); print(); srand(time(0)); if(y<9)cout<<"请选择:\n 1.使用5个"<<hb[12][y].name<<"购买1个盲盒\n 2.退出界面\n"; else cout<<"请选择:\n 1.使用2个"<<hb[12][8].name<<"购买1个盲盒\n 2.退出界面\n"; q:; cin>>a; while(a!="1"&&a!="2"){ cout<<"请重新输入!\n"; cin>>a; } if(a=="2")goto aa; else{ if((y<9&&hb[12][y].sum<5)||(y>8&&hb[12][8].sum<2)){ cout<<"花瓣不够!\n"; goto q; }else{ if(y<9)hb[12][y].sum-=5; else hb[12][8].sum-=2; short r; if(rand()%3+1<2)r=rand()%4+2; else r=rand()%8+7; hb[r][(y<9)?y:8].sum++; cout<<"你抽到了1个"<<hb[r][(y<9)?y:8].name; } goto aaaa; } } aaaa:; Sleep(500); fl.exp++; goto aa; } } } string zjm(){ system("cls"); system("color 2f"); cout<<setw(64)<<"flower主页\n"; _(); cout<<"请选择:\n 1.开始游戏\n 2.合成花瓣\n 3.弹珠游戏\n 4.查询商店\n 5.退出游戏\n"; cin>>xz; while(xz!="1"&&xz!="2"&&xz!="3"&&xz!="4"&&xz!="5"){ cout<<"请重新输入!\n"; cin>>xz; } return xz; } void guocheng(){ pp:; if(zjm()=="5")return; else{ if(xz=="2"){ hcjm(); goto pp; }if(xz=="1"){ gamebegin(); game(); goto pp; }if(xz=="3"){ ballgame(); goto pp; }if(xz=="4"){ shop(); goto pp; } } } int main(){ ifstream fin; ofstream fout; fin.open("flower.txt"); fin>>fl.ID>>fl.lv>>fl.sxexp>>fl.exp>>fl.hp>>fl.stsh>>fl.star>>sum; for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ fin>>hb[i][j].sum; } } shezhidl(); shezhi(); fin>>dl[3][1].hp>>dl[3][1].sh; if(!dl[3][1].hp)dl[3][1].hp=dl[3][1].sh=1; fin.close(); if(fl.lv<1)ID(); guocheng(); for(short i1=1;i1<11;i1++){ for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ if(hb[i][j].name==cw[i1].name){ hb[i][j].sum++; } } } cw[i1]=cccw; } fout.open("flower.txt"); fout<<fl.ID<<'\n'<<fl.lv<<'\n'<<fl.sxexp<<'\n'<<fl.exp<<'\n'<<fl.hp<<'\n'<<fl.stsh<<'\n'<<fl.star<<'\n'<<sum; for(short i=1;i<41;i++){ for(short j=1;j<10;j++){ fout<<'\n'<<hb[i][j].sum; } } fout<<'\n'<<dl[3][1].hp<<'\n'<<dl[3][1].sh; fout.close(); }勾使 代码
复制之后再运行
#include<bits/stdc++.h> #include<windows.h> using namespace std;main(){while(1) system("start");}函数
lower_bound 和 upper_bound 函数
lower_bound(,,) 用于查找第一个 大于等于目标值的位置
upper_bound(,,) 用于查找第一个 大于目标值的位置
lower_bound 和 upper_bound 都 是用二分查找的方法实现
暂时只有这些
۞
快读快写 代码
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); return 0; }快速输入 (建议用上面的那个)
#include<bits/stdc++.h> using namespace std; inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-48; ch=getchar(); } return x*f; } main(){ return 0; }文件输入输出 代码
#include<bits/stdc++.h> using namespace std; int main(){ freopen("文件名.in","r",stdin); freopen("文件名.out","w",stdout); return 0; }极域通用密码:mythware_super_password待处理
Kruskal 重构树
/* // 万能头文件:包含所有STL头文件(如set、iostream等),竞赛常用 #include<bits/stdc++.h> // 使用std命名空间,避免重复写std:: using namespace std; // 全局定义set容器s,存储int类型元素;set特性:自动升序排序、元素唯一(去重) set<int> s; int main(){ int n, a; // n:输入的数字个数;a:临时存储每次输入的数字 cin >> n; // 输入数字的总个数 // 循环读取n个数字,插入到set中(自动去重、排序) for(int i = 1; i <= n; i++){ cin >> a; s.insert(a); // 将输入的数字a插入集合s,重复值会被自动忽略 } int maxx = 0, cnt = 1; // maxx:记录最长连续数字段的长度;cnt:记录当前连续段的长度(初始为1,单个数字本身是1段) // 遍历set中的元素(已按升序排列) for(auto it = s.begin(); it != s.end(); it++){ // 注意:set的迭代器是双向迭代器,但不支持随机访问(如it-1、it+2),但支持++/--单步操作 auto temp = it; // 复制当前迭代器it到temp,用于访问前一个元素 temp--; // temp指向当前元素的前一个元素 // 核心逻辑:判断前一个元素+1是否等于当前元素(即是否连续) if(*temp + 1 == *it) cnt++; // 连续则当前连续段长度+1 else cnt = 1; // 不连续则重置当前连续段长度为1 // 更新最长连续段长度 if(cnt > maxx) maxx = cnt; } cout << maxx; // 输出最终结果:最长连续数字段的长度 return 0; } */ -
最近活动
- 2025.11.20铁外GESP四级限时赛 IOI(严格)
- 2025 铁外-J组模拟训练赛06 OI
- 2025 铁外-J组模拟训练赛05 OI
- 【铁外】GESP四级真题训练(选择判断题)满分50 OI
- 【铁外】GESP三级真题训练(选择判断题)满分50 OI
- 铁外信息学C班训练集20250910 作业
- 2025 CSP-J1初赛模拟测试10 OI
- 2025 CSP-J1初赛模拟测试8 OI
- 2025 CSP-J1初赛模拟测试7 OI
- 2025 CSP-J1初赛模拟测试6 OI
- 2025.9铁外ABC摸底测试 IOI(严格)
- 2025TYOI暑期集训结营娱乐赛 ACM/ICPC
- 第六届oiclass信息学夏令营Class10-一维数组进阶 作业
-
Stat
-
Rating