碎碎念

比赛前看到评论区的提问
这个是干啥的,求解答,第一次参加
抽奖送牛客卫衣的
hhhh重在参与

然后【注意事项】里面写的
1 参赛形式:个人,面向零基础20级新生和部分有基础新生。
4 请各位教练约束一下自己学生,老队员尽量不要参加,至少不要带歪榜
5 因我校新生水平有限,题目比较简单。题目或者网络若有问题请各位教练和同学们多多担待
说好的水赛呢?水在哪里嘤嘤嘤

之前老师在社团群里随手发了个,我还以为是推荐呢,结果下午好像就我来打了?
我,qaqwq

按照过题率做了BDEIKL一共6题
G思路是对的,但是不知道为啥一直没过,补一下

剩下五题题目没看就算了,害。

签到语法题:B、I

  • B就是一个字符串统计O(n)枚举就行了
  • I是一个直接输出答案的签到题,,(Ctrl+F搜冠军,数一下就行)
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
int cnt = 0;
while(cin>>s){
if(s==".")break;
for(int i = 0; i < s.size(); i++){
if(s[i]=='a')cnt++;
}
}
cout<<cnt<<"\n";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main(){
cout<<"The Chinese teams has won 4 championships\n";
return 0;
}

签到模拟题:K,L

  • K是一个数组模拟,会vector迭代器就白给
  • L是一个直接开方计算,注意360度的时候分个类。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<int>a;
int main(){
int n, q;
cin>>n>>q;
for(int i = 0; i < n; i++){
int x; cin>>x; a.push_back(x);
}
while(q--){
int op; cin>>op;
if(op==1){
int x; cin>>x;
a.erase(a.begin()+x-1);
}else if(op==2){
int x, y; cin>>x>>y;
vector<int>::iterator it = a.begin()+x-1;
a.insert(it,y);
}else if(op==3){
int x; cin>>x;
vector<int>::iterator it = a.begin()+x-1;
int t = *it, tt = *it; it++;
while((*it)==t && it<a.end()){
tt += t;
it++;
}
a.erase(a.begin()+x-1,it);
a.insert(a.begin()+x-1,tt);
}
for(int i = 0; i < a.size(); i++){
if(i!=0)cout<<" ";
cout<<a[i];
}
cout<<"\n";
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const double pi = 3.1415926535;
int main(){
//cout<<pi<<endl;
int T; cin>>T;
while(T--){
int a, b, r, h;
cin>>a>>b>>r>>h;
double x = min(abs(a-b),360-abs(a-b))*1.0/360*2*pi*r;
double ans = sqrt(x*x+1.0*h*h);
printf("%.2lf\n",ans*ans);
}
return 0;
}

签到数学题:D、E

  • 求n的阶乘在m进制下末位0的个数。这题CF有原题,这题是素数,简化了问题,可以直接转换为:n中p因子个数,然后循环就好了。结论是​​n/p+n/(p^2)+n/(p^3)​​。
  • k为gcd的因子,等价于同时满足k是i和j的因数,即有多少个i和j都是k的倍数。所以答案直接输出​​(n/k)*(m/k)​​。(这题我还绕了好久要不要循环求k平方的倍数,不过已经包含了)
  • 这两题的坑是要记得开longlong,emmm
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int T; cin>>T;
while(T--){
int n, p; cin>>n>>p;
LL cnt = 0, tmp = 1;
for(int i = 1; i <= n; i++){
tmp *= i;
if(tmp%p==0){
cnt++; tmp/=p;
}
}
cout<<cnt<<"\n";
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
int T; cin>>T;
while(T--){
LL n, m, k;
cin>>n>>m>>k;
if(k==1){
cout<<n*m<<endl;
continue;
}
LL cnt = 0, t1, t2;
t1 = n/k, t2 = m/k;
cnt += t1*t2;
cout<<cnt<<endl;
}
return 0;
}

补题,G

  • 无论以任何顺序入场,怒气值之和都不会改变。(结论我已经得出来了)
  • 可是不知道为什么单跑一遍还是会TLE,我直接qaq
  • 还是想不懂自己下午为什么会傻傻的写错,qaq
//结论,直接计算就行
//n个座位,m个人(按照一定排列进入)有心仪座位
//如果做不到心仪的,怒气值为右边以第一个空的到心仪的位置
//求安排顺序让怒气值最小
//记得开longlong
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[100010];

int main(){
int n, m; cin>>n>>m;
for(int i = 1; i <= m; i++)
cin>>a[i];
sort(a+1,a+m+1);//排序是
LL ans = 0, s = 1;
for(int i = 1; i <= n; i++){
if(a[s]<=i){//如果心仪座位在i左边,那就走过来,积累怒气值
ans += i-a[s];
s++;
}
if(s==m+1)break;
}
if(s!=m+1)cout<<-1;
else cout<<ans;
return 0;
}

/*
/*
//贪心,每个人先选好自己的位置
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 100010;
int a[maxn];
set<int>se;
int main(){
ios::sync_with_stdio(false);
int n, m; cin>>n>>m;
for(int i = 1; i <= m; i++){
cin>>a[i]; se.insert(a[i]);
}
sort(a+1,a+m+1);
int ans = 0;
for(int i = 1; i <= m; i++){
if(a[i]==a[i-1]){
int t = a[i];
while(se.count(t))t++;
if(t>n){cout<<-1;return 0;}
se.insert(t);
ans += t-a[i];
}
}
cout<<ans<<"\n";
return 0;
}
*/
/*
//贪心:所有顺序结果都一样,直接计算
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 100010;
int a[maxn];
set<int>se;
vector<int>vc;
int main(){
int n, m;
cin>>n>>m;
int ans = 0;
for(int i = 1; i <= m; i++){
cin>>a[i]; int t = a[i];
while(se.count(t))t++;
if(t>n){
cout<<"-1";
return 0;
}
se.insert(t);
ans += t-a[i];
}

cout<<ans<<"\n";
return 0;
}
*/


/*
//枚举排列
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 100010;
int a[maxn], sc[maxn];
int main(){
int n, m;
cin>>n>>m;
for(int i = 1; i <= m; i++)
cin>>a[i];
int ans = -1;
do{
memset(sc,0,sizeof(sc));
int tmp = 0;
for(int i = 1; i <= m; i++){
int t = a[i];
while(sc[t]!=0)t++;
if(t>n){
tmp =-1e9;
}
sc[t] = i;
tmp += t-a[i];
}
ans = max(ans,tmp);
}while(next_permutation(a+1,a+m+1));
cout<<ans<<"\n";
return 0;
}
*/

官方题解

牛客竞赛,GDDU第十届文远知行杯新生程序设计竞赛,摸鱼记(BDEIKL题解,补G,ACFHJ)_ci


牛客竞赛,GDDU第十届文远知行杯新生程序设计竞赛,摸鱼记(BDEIKL题解,补G,ACFHJ)_ci_02


牛客竞赛,GDDU第十届文远知行杯新生程序设计竞赛,摸鱼记(BDEIKL题解,补G,ACFHJ)_#include_03


牛客竞赛,GDDU第十届文远知行杯新生程序设计竞赛,摸鱼记(BDEIKL题解,补G,ACFHJ)_ci_04