cometoj(A-D+F+H)代码
A
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<queue> #include<stack> #include<set> #include<map> #include<vector> #include<cmath> const int maxn=1e5+5; typedef long long ll; using namespace std; int main() { ll n; scanf("%lld",&n); ll ss=(1+n)*n/2; ss+=(n)*(n-1)/2; printf("%lld",ss); return 0; }
B
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> #include<stack> #include<set> #include<map> #include<vector> #include<cmath> const int maxn=1e5+5; typedef long long ll; using namespace std; int a[15]; int vis[15]; int main() { int T; cin>>T; int n; while(T--) { scanf("%d",&n); for(int t=0;t<n;t++) { scanf("%d",&a[t]); } int maxx=0; for(int t=0;t<1<<n;t++) { memset(vis,0,sizeof(vis)); for(int j=0;j<n;j++) { vis[n-1-j]=t>>j&1; } int sum=0; for(int j=0;j<n;j++) { if(vis[j]==1) { sum++; } } bool flag=false; for(int j=0;j<n;j++) { for(int k=j+1;k<n;k++) { if(vis[j]==1&&vis[k]==1) { if(__gcd(a[j],a[k])!=1) { flag=true; } } } } if(flag==false) { maxx=max(maxx,sum); } } printf("%d\n",maxx); } return 0; }
C
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<queue> #include<stack> #include<set> #include<vector> #include<map> #include<cmath> const int maxn=1e5+5; typedef long long ll; using namespace std; char str1[10*maxn],str2[10*maxn]; int main() { int T; cin>>T; while(T--) { scanf("%s%s",str1,str2); int len1=strlen(str1); int len2=strlen(str2); if(len1==len2+2) { int cnt=0; for(int t=0;t<len1;t++) { if(str2[cnt]==str1[t]) { cnt++; } } if(cnt==len2) { printf("1\n"); } else { printf("0\n"); } } else { printf("0\n"); } } return 0; }
D:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+5;
typedef long long ll;
using namespace std;
int a[20]; int vis[25]; int main() { int x; for(int t=0;t<18;t++) { scanf("%d",&x); vis[x]++; } for(int t=1;t<14;t++) { if(vis[t]%2==0) { vis[t]=0; } else { vis[t]=1; } } int ans=0; for(int t=0;t<14;t++) { ans+=vis[t]; } cout<<ans<<endl; return 0; }
F:
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<queue> #include<stack> #include<set> #include<vector> #include<map> #include<cmath> const int maxn=1e5+5; typedef long long ll; using namespace std; int vis[1005][1005]; int dir[9][2]={{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0}}; int n,m; bool check(int x,int y) { if(x>=1&&x<=n&&y>=1&&y<=m) { return true; } else { return false; } } int main() { int q; cin>>n>>m>>q; int ans=(n-1)*(m-1); int x,y; while(q--) { scanf("%d%d",&x,&y); vis[x][y]=1; int cnt=0; for(int t=0;t<3;t++) { int xx=x+dir[t][0]; int yy=y+dir[t][1]; if(check(xx,yy)&&vis[xx][yy]==0) { cnt++; } } if(cnt==3) { ans--; } cnt=0; for(int t=2;t<5;t++) { int xx=x+dir[t][0]; int yy=y+dir[t][1]; if(check(xx,yy)&&vis[xx][yy]==0) { cnt++; } } if(cnt==3) { ans--; } cnt=0; for(int t=4;t<7;t++) { int xx=x+dir[t][0]; int yy=y+dir[t][1]; if(check(xx,yy)&&vis[xx][yy]==0) { cnt++; } } if(cnt==3) { ans--; } cnt=0; for(int t=6;t<9;t++) { int xx=x+dir[t][0]; int yy=y+dir[t][1]; if(check(xx,yy)&&vis[xx][yy]==0) { cnt++; } } if(cnt==3) { ans--; } printf("%d\n",ans); } return 0; }
H:
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<queue> #include<stack> #include<set> #include<vector> #include<map> #include<cmath> const int maxn=1e5+5; typedef long long ll; using namespace std; int a[2*maxn]; int main() { int n; cin>>n; for(int t=0;t<n;t++) { scanf("%d",&a[t]); } bool down=true; int h=0x3f3f3f3f; int ans=0; for(int t=0;t<n;t++) { if(down) { if(a[t]>=h) { down=false; ans++; } } else { if(a[t]<=h) { down=true; } } h=a[t]; } cout<<ans<<endl; return 0; }
作者:李斌
-------------------------------------------
个性签名:独学而无友,则孤陋而寡闻。做一个灵魂有趣的人!
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!
万水千山总是情,打赏一分行不行,所以如果你心情还比较高兴,也是可以扫码打赏博主,哈哈哈(っ•̀ω•́)っ✎⁾⁾!
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步