当前位置: 首页 > news >正文

2024 第五次周赛

A: 直接遍历即可

#include<bits/stdc++.h>
using namespace std;typedef long long ll;
typedef pair<ll, ll>PII;
const int N = 2e6 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;int n, m;
int main()
{cin >> n;int cnt = 0;for(int i = 0; i <= n; i ++){if((i ^ (2 * i) ^ (3 * i)) == 0) cnt ++;}cout << cnt << endl;return 0;
}

B:模拟,转置得性质a[i][j] = a[j][i], 模拟一些即可

#include <iostream>
using namespace std; 
int main() 
{int m,n;int a[501][501];int i,j;cin>>m>>n;//输入矩阵列数、行数for(i=1;i<=m;i++)//输入矩阵for(j=1;j<=n;j++)cin>>a[i][j];cout << n << " " << m << endl;for(i=1;i<=n;i++)//输出转至后的矩阵{for(j=1;j<=m;j++)cout<<a[j][i]<<" ";cout<<endl;}return 0;
}

C:二分枚举这个最大得距离,然后for循环遍历这些隔间之间得距离差,最后枚举出来即可:

#include<iostream>
#include<algorithm>
using namespace std;const int N = 1e5 + 10;
typedef long long ll;
int n, c;
int a[N];bool check(int x)
{int cnt = 1, mins = a[1];for(int i = 2; i <= n; i ++){if(a[i] - mins >= x){cnt ++;mins = a[i];}}if(cnt >= c) return true;//说明安排的距离小else return false;// 说明安排的距离大
}
int main()
{cin >> n >> c;for(int i = 1; i <= n; i ++){cin >> a[i];}//二分前都需要排序sort(a + 1, a + 1 + n);int l = 0, r = a[n] - a[1] + 1;while(l + 1 != r){int mid = l + r >> 1;if(check(mid)) l = mid;else r = mid;}cout << l << endl;return 0;
}

D:shishan模拟,根据题意模拟即可,不要求思维含量:

#include<iostream>
using namespace std;
#include<algorithm>
string yw[30]={"","one","two","three","four","five","six","seven","eight","nine","ten","elven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","a","both","another","first","second","third"}; 
int sz[30]={0,1,4,9,16,25,36,49,64,81,0,21,44,69,96,25,56,89,24,61,0,1,4,1,1,4,9};
int k;
int a[10];int main()
{for(int i=1;i<=6;i++){string x;cin>>x;for(int j=1;j<=26;j++){if(yw[j]==x){a[++k]=sz[j];break;}}}if(k==0){cout<<0<<endl;return 0;}sort(a+1,a+k+1);for(int i=1;i<=k;i++){if(i!=1&&a[i]<10)cout<<0;cout<<a[i];}cout<<endl;return 0;
}

E:在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;typedef long long ll;
typedef pair<int ,int>PII;
const ll N = 3e5 + 5,M = 3e5;
const ll mod = 1e9 + 7;
ll n , a, b, ni[N];
ll kmi(ll a, ll b)
{ll res = 1;while(b){if(b & 1){res = res * a % mod;}a = a * a % mod;b >>= 1;}return res;
}
ll C(ll n , ll m)
{ll ans = 1;for(int i = 1;i <= m;i ++){ans = ans * (n - m + i) % mod * ni[i]%mod;}return ans;
}
int main(){cin >> n >> a >> b;for(int i = 1;i <= M;i ++)ni[i] = kmi(i,mod - 2);ll ans = (kmi(2, n) - C(n ,a) - C(n, b) - 1 + 3 * mod)%mod;printf("%lld",ans);return 0;
}

http://www.mrgr.cn/news/69825.html

相关文章:

  • OSPF总结
  • 工程数学线性代数(同济第七版)附册课后习题答案PDF
  • Elasticsearch中什么是倒排索引?
  • Git核心概念
  • FPGA实现PCIE3.0视频采集转SDI输出,基于XDMA+GS2971架构,提供工程源码和技术支持
  • vue内置方法总结
  • Python根据指定代理IP,创建AdsPower指纹浏览器窗口
  • “掌握AI绘画技巧:Stable Diffusion高质量图像生成之提示词撰写指南“
  • Entity Framework的简单使用案例
  • Java代码操作ZooKeeper(使用原生 ZooKeeper 客户端库)
  • SpringBoot框架的简介及实现步骤
  • GPT-5 终于来了 —— 人们的预期与现实
  • 人工智能在智能交通系统中的应用
  • 4.3软件设计:面对对象的设计
  • 洛古---越狱问题【快速幂】
  • python manage.py命令集
  • Spring IOC 和Spring Aop
  • 漫谈分布式唯一ID
  • 【双十一特惠】腾讯云省钱攻略:如何智取云计算资源
  • goframe开发一个企业网站 rabbitmq队例15
  • p4dctl命令工具
  • 丹摩征文活动|Faster-Rcnn-训练与测试详细教程
  • [NeurIPS 2024]Long-range Brain Graph Transformer
  • Spark:背压机制
  • 优选算法 - 1 ( 双指针 移动窗口 8000 字详解 )
  • 简单的链表相加