2020年西安电子科技大学新生赛现场赛代码
2021/11/26 23:40:14
本文主要是介绍2020年西安电子科技大学新生赛现场赛代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#include<stdio.h> #include<algorithm> using namespace std; #define M 100005 int A[M],n; int main(){ scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&A[i]); sort(A,A+n); printf("Bogosort:"); for(int i=n-1;i>=0;i--) printf(" %d",A[i]); puts(""); return 0; }
#include<bits/stdc++.h> #define M 100005 #define LL long long using namespace std; struct node{LL x,y;}A[M],sum; int n,cnt; bool check(){ for(int i=1;i<=n;i++){ node tmp;tmp.x=sum.x-A[i].x;tmp.y=sum.y-A[i].y; if(tmp.x*tmp.x+tmp.y*tmp.y==A[i].x*A[i].x+A[i].y*A[i].y) return 1; if(tmp.x==0&&tmp.y==0)return 1; if(!(A[i].x==0&&A[i].y==0)&&tmp.y*A[i].x==A[i].y*tmp.x)return 1; } return 0; } int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld%lld",&A[i].x,&A[i].y); sum.x+=A[i].x; sum.y+=A[i].y; } if(check())puts("yes"); else puts("no"); return 0; }
#include<bits/stdc++.h> #define LL long long #define M 1000005 using namespace std; LL n; int pri[M];bool mark[M]; void Init(){ for(int i=2;i<M;i++){ if(!mark[i])pri[++pri[0]]=i; for(int j=i+i;j<M;j+=i) mark[j]=1; } } int main(){ Init(); scanf("%lld",&n); LL ans=1; for(int i=1;i<=pri[0];i++){ if(n%pri[i]==0) ans*=pri[i]; while(n%pri[i]==0)n/=pri[i]; } printf("%lld\n",n*ans); return 0; }
#include<bits/stdc++.h> #define M 100005 using namespace std; int n,D,in[M]; int main(){ scanf("%d%d",&n,&D); for(int i=1,a,b;i<n;i++){ scanf("%d%d",&a,&b); in[a]++;in[b]++; } int ans=0; for(int i=1;i<=n;i++){ if(in[i]>D){ int res=(in[i]-D)/(D-2); if((in[i]-D)%(D-2)!=0)res++; if(res<0)res=0; ans+=res; } } printf("%d\n",ans); return 0; }
#include<bits/stdc++.h> #define M 100005 using namespace std; int n,T,t; int main(){ cin>>T; while(T--){ scanf("%d%d",&n,&t); if(n==1)puts(":-)"); else if(t==1){ if(n%2==0)puts(":-("); else puts(":-)"); } else puts(":-("); } return 0; }
#include<bits/stdc++.h> #define M 100005 using namespace std; int n,cur=1; char S[M],mx[M]; int main(){ scanf("%d%s",&n,S+1); for(int i=1;i<=n;i++)mx[i]=max(mx[i-1],S[i]); for(int i=2;i<n;i++) if(S[i]<mx[cur])cur=i; sort(S+1,S+cur+1); sort(S+cur+1,S+n+1); puts(S+1); return 0; }
#include<bits/stdc++.h> #pragma GCC optimize(2) #define LL long long #define M 400005 using namespace std; int n; LL mv,l; map<int,int>mp; map<int,int>::iterator it; int main(){ scanf("%lld%d",&l,&n); while(n--){ int op;LL x; scanf("%d%lld",&op,&x); if(op==1){ x-=mv;x=(x%l+l)%l; mp[x]++; } else if(op==2){ x-=mv;x=(x%l+l)%l;mp[x]--; if(mp[x]==0)mp.erase(x); } else if(op==3)mv+=x; else { LL a,b;x-=mv;x=(x%l+l)%l; it=mp.lower_bound(x); if(it!=mp.end())a=it->first; else a=mp.begin()->first; if(it!=mp.begin()){it--;b=it->first;} else {it=mp.end();it--;b=it->first;} x+=mv;x=(x+l)%l;a=(a+mv)%l;b=(b+mv)%l; if(a>b)swap(a,b);if(min(l-abs(a-x),abs(a-x))>min(l-abs(b-x),abs(b-x)))swap(a,b); printf("%lld\n",a); } } return 0; }
#include<bits/stdc++.h> #define LL long long #define M 35 using namespace std; const int mod=1e9+7; int n,m,cnt[M]; bool G[M][M]; bool vis[M]; void dfs(int x){ cnt[x]++;vis[x]=1; for(int i=1;i<=n;i++) if(G[x][i]&&!vis[i])dfs(i); } LL Ans; LL qkpow(LL a,LL b){ LL ans=1; while(b){ if(b&1)ans=ans*a%mod; a=a*a%mod; b>>=1; } return ans; } int main(){ cin>>n>>m; for(int i=1,a,b;i<=m;i++){ scanf("%d%d",&a,&b); G[a][b]=1; } for(int i=1;i<=n;i++){ memset(vis,0,sizeof(vis)); dfs(i); } for(int i=1;i<=n;i++) Ans=(Ans+qkpow(cnt[i],mod-2))%mod; printf("%lld\n",Ans); return 0; }
这篇关于2020年西安电子科技大学新生赛现场赛代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)