当前位置:网站首页>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
边栏推荐
- 根据热门面试题分析Android事件分发机制(二)---事件冲突分析处理
- flinkcdc采集oracle在snapshot阶段一直失败,这个得怎么调整啊?
- CSDN salary increase technology - learn about the use of several common logic controllers of JMeter
- 在EXCEL写VBA连接ORACLE并查询数据库中的内容
- Communication mode between processes
- H5网页播放器EasyPlayer.js如何实现直播视频实时录像?
- Elaborate on MySQL mvcc multi version control
- Schema-validation: wrong column type encountered in column XXX in table XXX
- Jenkins modifies the system time
- Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
猜你喜欢
Jenkins modifies the system time
Loxodonframework quick start
Using JWT to realize login function
浏览器中如何让视频倍速播放
First issue of JS reverse tutorial
基础篇:带你从头到尾玩转注解
[4g/5g/6g topic foundation -147]: Interpretation of the white paper on 6G's overall vision and potential key technologies -2-6g's macro driving force for development
[bw16 application] Anxin can realize mqtt communication with bw16 module / development board at instruction
信息安全实验一:DES加密算法的实现
Unity shader (to achieve a simple material effect with adjustable color attributes only)
随机推荐
shake数据库中怎么使用Mongo-shake实现MongoDB的双向同步啊?
Jenkins modifies the system time
农牧业未来发展蓝图--垂直农业+人造肉
flinkcdc 用sqlclient可以指定mysqlbinlog id执行任务吗
Huawei HCIP - datacom - Core 03 jours
【BW16 应用篇】安信可BW16模组/开发板AT指令实现MQTT通讯
Netease Cloud Wechat applet
Difference between process and thread
创建一个长度为6的int型数组,要求数组元素的值都在1-30之间,且是随机赋值。同时,要求元素的值各不相同。
VSCode+mingw64
Strategic cooperation subquery becomes the secret weapon of Octopus web browser
Unity shader (data type in cghlsl)
How does mongodb realize the creation and deletion of databases, the creation of deletion tables, and the addition, deletion, modification and query of data
面试被问到了解哪些开发模型?看这一篇就够了
基于智慧城市与储住分离数字家居模式垃圾处理方法
asp. How to call vb DLL function in net project
Regular matching starts with XXX and ends with XXX
进程和线程的区别
La différence entre viewpager 2 et viewpager et la mise en œuvre de la rotation viewpager 2
How to become a senior digital IC Design Engineer (5-3) theory: ULP low power design technology (Part 2)