当前位置:网站首页>20排位赛3
20排位赛3
2022-07-07 07:09:00 【moyangxian】
A
题意:略
题记:略
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int a[N];
int main(){
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
cout<<max(0,a[2]-a[1]-a[0]+1)<<endl;
return 0;
}
B
题意:略
题记:找字符串的最长公共前后缀,用substr()函数或者求next函数。
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int nxt[N];
char s[N];
int n,k;
void getnext(){
int i=0,j=-1;
nxt[0]=-1;
while(i<n){
if(j==-1||s[i]==s[j])
i++,j++,nxt[i]=j;
else
j=nxt[j];
}
}
int main(){
cin>>n>>k;
cin>>s;
getnext();
cout<<s;
for(int i=1;i<=k-1;i++)
cout<<(s+nxt[n]);
return 0;
}
C
题意:略
题记:总共可以看到n/x个灯笼,r/x表示1~ r能看到多少灯笼,(l-1)/x表示1 ~ (l-1)能看到多少灯笼。(n/x)-r/x+(l-1)/x即答案。
#include<bits/stdc++.h>
using namespace std;
const int N=110;
void solve(){
int n,x,l,r;
cin>>n>>x>>l>>r;
cout<<(n/x)-r/x+(l-1)/x<<endl;
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
return 0;
}
D
题意:略
题记:每次sum都能减去一个(a-b),所以将(a-b)作为关键字降序排序,每次将sum减一下即可。最后再判断一下sum是否大于m。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
struct Node{
int a,b;
bool operator<(const Node &W)const{
return a-b>W.a-W.b;
}
}t[N];
void solve(){
int n,m;
cin>>n>>m;
ll sum=0;
for(int i=1;i<=n;i++){
cin>>t[i].a>>t[i].b;
sum+=t[i].a;
}
sort(t+1,t+1+n);
int ans=0;
for(int i=1;i<=n;i++){
if(sum<=m) break;
sum-=t[i].a-t[i].b;
ans++;
}
if(sum<=m) cout<<ans<<endl;
else cout<<"-1"<<endl;
}
int main(){
int T=1;
//cin>>T;
while(T--){
solve();
}
return 0;
}
E
题意:略
题记:
C语言的sin函数需要传递的是弧度,弧度=角度*pi/180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);
int main(){
double n,r;
cin>>n>>r;
double s=sin(360/(n*2)*(pi/180));
double ans=(s*r)/(1-s);
printf("%.8f\n",ans);
return 0;
}
F
G
边栏推荐
- JMeter JDBC batch references data as input parameters (the simplest method for the whole website)
- [4g/5g/6g topic foundation-146]: Interpretation of white paper on 6G overall vision and potential key technologies-1-overall vision
- js逆向教程第二发-猿人学第一题
- PostgreSQL reports an error when creating a trigger,
- 用flinksql的方式 写进 sr的表,发现需要删除的数据没有删除,参照文档https://do
- flink. CDC sqlserver. 可以再次写入sqlserver中么 有连接器的 dem
- Install pyqt5 and Matplotlib module
- What development models did you know during the interview? Just read this one
- 沙龙预告|GameFi 领域的瓶颈和解决方案
- 大佬们,有没有遇到过flink cdc读MySQLbinlog丢数据的情况,每次任务重启就有概率丢数
猜你喜欢

战略合作|SubQuery 成为章鱼网络浏览器的秘密武器

Kubernetes cluster capacity expansion to add node nodes

NATAPP内网穿透

The configuration and options of save actions are explained in detail, and you won't be confused after reading it

How to speed up video playback in browser

Octopus future star won a reward of 250000 US dollars | Octopus accelerator 2022 summer entrepreneurship camp came to a successful conclusion

信息安全实验一:DES加密算法的实现
![[Frida practice]](/img/20/fc68bcf2f55b140d6754af6364896b.png)
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform

Strategic cooperation subquery becomes the secret weapon of Octopus web browser

Impression notes finally support the default markdown preview mode
随机推荐
ComputeShader
Add new item after the outbound delivery order of SAP mm sto document is created?
Pick up the premise idea of programming
網易雲微信小程序
大佬们,有没有遇到过flink cdc读MySQLbinlog丢数据的情况,每次任务重启就有概率丢数
[4G/5G/6G专题基础-147]: 6G总体愿景与潜在关键技术白皮书解读-2-6G发展的宏观驱动力
进程间的通信方式
How will fashion brands enter the meta universe?
Upload taro pictures to Base64
JS逆向教程第一发
Kubernetes cluster capacity expansion to add node nodes
flink. CDC sqlserver. 可以再次写入sqlserver中么 有连接器的 dem
Liunx command
信息安全实验三 :PGP邮件加密软件的使用
esp8266使用TF卡并读写数据(基于arduino)
嵌套(多级)childrn路由,query参数,命名路由,replace属性,路由的props配置,路由的params参数
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
Create an int type array with a length of 6. The values of the array elements are required to be between 1-30 and are assigned randomly. At the same time, the values of the required elements are diffe
Huawei hcip datacom core_ 03day
二叉树高频题型