cometoj(A-D+F+H)代码
2024-10-09 16:10:46
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+;
typedef long long ll;
using namespace std; int main()
{
ll n;
scanf("%lld",&n);
ll ss=(+n)*n/;
ss+=(n)*(n-)/;
printf("%lld",ss);
return ;
}
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+;
typedef long long ll;
using namespace std;
int a[];
int vis[];
int main()
{
int T;
cin>>T;
int n;
while(T--)
{
scanf("%d",&n);
for(int t=;t<n;t++)
{
scanf("%d",&a[t]);
}
int maxx=;
for(int t=;t<<<n;t++)
{
memset(vis,,sizeof(vis));
for(int j=;j<n;j++)
{
vis[n--j]=t>>j&;
}
int sum=;
for(int j=;j<n;j++)
{
if(vis[j]==)
{
sum++;
}
}
bool flag=false;
for(int j=;j<n;j++)
{
for(int k=j+;k<n;k++)
{
if(vis[j]==&&vis[k]==)
{
if(__gcd(a[j],a[k])!=)
{
flag=true;
}
}
}
}
if(flag==false)
{
maxx=max(maxx,sum);
} }
printf("%d\n",maxx);
} return ;
}
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+;
typedef long long ll;
using namespace std; char str1[*maxn],str2[*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+)
{
int cnt=;
for(int t=;t<len1;t++)
{
if(str2[cnt]==str1[t])
{
cnt++;
}
}
if(cnt==len2)
{
printf("1\n");
}
else
{
printf("0\n");
}
}
else
{
printf("0\n");
}
}
return ;
}
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+;
typedef long long ll;
using namespace std;
int vis[][];
int dir[][]={{-,},{-,-},{,-},{,-},{,},{,},{,},{-,},{-,}};
int n,m;
bool check(int x,int y)
{
if(x>=&&x<=n&&y>=&&y<=m)
{
return true;
}
else
{
return false;
}
}
int main()
{
int q;
cin>>n>>m>>q;
int ans=(n-)*(m-);
int x,y;
while(q--)
{
scanf("%d%d",&x,&y);
vis[x][y]=;
int cnt=;
for(int t=;t<;t++)
{
int xx=x+dir[t][];
int yy=y+dir[t][];
if(check(xx,yy)&&vis[xx][yy]==)
{
cnt++;
} }
if(cnt==)
{ ans--;
}
cnt=;
for(int t=;t<;t++)
{
int xx=x+dir[t][];
int yy=y+dir[t][];
if(check(xx,yy)&&vis[xx][yy]==)
{
cnt++;
} }
if(cnt==)
{ ans--;
}
cnt=;
for(int t=;t<;t++)
{
int xx=x+dir[t][];
int yy=y+dir[t][];
if(check(xx,yy)&&vis[xx][yy]==)
{
cnt++;
} }
if(cnt==)
{ ans--;
}
cnt=;
for(int t=;t<;t++)
{
int xx=x+dir[t][];
int yy=y+dir[t][];
if(check(xx,yy)&&vis[xx][yy]==)
{
cnt++;
} }
if(cnt==)
{ ans--;
}
printf("%d\n",ans); }
return ;
}
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+;
typedef long long ll;
using namespace std;
int a[*maxn];
int main()
{
int n;
cin>>n;
for(int t=;t<n;t++)
{
scanf("%d",&a[t]);
}
bool down=true;
int h=0x3f3f3f3f;
int ans=;
for(int t=;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 ;
}
最新文章
- 4、解析配置文件 redis.conf、Redis持久化RDB、Redis的主从复制
- Excel中如何过滤复选框 How to filter checkbox column in Excel
- MarkDown初体验
- 002 C#学前入门
- 2016.02.17 JS DOM编程艺术 第四五六章
- 关于移动端的font和图片的问题
- 解决“Xlib.h not found when building graphviz on Mac OS X 10.8”错误
- API测试自动化——基于CDIF的SOA基本功能(实例篇)
- R语言命令行参数
- [C#] 获取计算机内部信息 - ComputerInfoHelper
- MongoDB远程维护客户端工具的使用!
- 如何写jquery插件
- Python两个栈实现一个队列
- 解决openoffice进程异常退出的办法
- mysql修改表结构语句
- iOS 扩展类方法之category!
- TypeError: &#39;newline&#39; is an invalid keyword argument for this function 错误解决
- 如何选择 .NET Framework目标版本
- 解析Java的JNI编程中的对象引用与内存泄漏问题
- 将Android studio的工程导入到eclipse中