常州大学新生寒假训练会试(重现赛)

比赛地址
A.
思路:直接STL调用string类库函数就行

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    for(int i=3;i<s.length();i+=3){
        s.insert(i,",");
        i++;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}

B.
思路:只要行或者是列出现偶数,就肯定不可能出现中心位置,这是显而易见的,当行和列都是奇数,即中心位置能出现时,每次(n-1)/2,(m-1)/2,将行和列减半得到的是中心位置的坐标,每得到一次都需要将个数*4,由对称性可知,这也是很显然的

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

ll quick_pow(ll x,ll y)
{
    ll ans=1;
    while(y){
        if(y&1)ans=ans*x;
        x=x*x;
        y>>=1;
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll sum=0,ans=1;
    if(n%2==0||m%2==0){
        sum=0;
    }else{
        while((n&1)&&(m&1)){
            n=(n-1)/2,m=(m-1)/2;
            sum+=ans;
            ans*=4;
        }
    }
    cout<<sum<<endl;
    return 0;
}

C.
思路:优先队列

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>

using namespace std;

struct node{
    int h,m,s;
    friend bool operator < (node n1,node n2){
        if(n1.h==n2.h){
            if(n1.m==n2.m)return n1.s>n2.s;
            return n1.m>n2.m;
        }
        return n1.h>n2.h;
    }
};

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a,b,c;
    priority_queue<node> pq;
    node nd;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        nd.h=a,nd.m=b,nd.s=c;
        pq.push(nd);
    }
    while(!pq.empty()){
        nd=pq.top();pq.pop();
        cout<<nd.h<<' '<<nd.m<<' '<<nd.s<<endl;
    }
    return 0;
}

D.
思路:DP+STL,参考重现赛大佬题解

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>

using namespace std;

typedef long long ll;
const int N=1e5+10;
ll dp[N];

struct node{
    ll id,pri;
};

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    memset(dp,0,sizeof(dp));
    node nd[N];
    deque<node> pq;
    ll sum=0;
    for(int i=1;i<=n;i++){
        cin>>nd[i].pri;
        nd[i].id=i;
        sum+=nd[i].pri;
    }
    for(int i=1,pos=0;i<=n;i++,pos++){
        while(!pq.empty()&&dp[pos]<=pq.back().pri)pq.pop_back();
        pq.push_back({pos,dp[pos]});
        if(pos-pq.front().id>k)pq.pop_front();
        dp[i]=pq.front().pri+nd[i].pri;
    }
    for(int i=n-k+1;i<=n;i++){
        dp[i]=min(dp[i],dp[i-1]);
    }
    cout<<sum-dp[n]<<endl;
    return 0;
}

E.
思路:数学推导,推出公式:Ai=A0+(An-A0)/n*i

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

typedef long long ll;

int main()
{
    int n,a0,an,q,l,r;
    cin>>n>>a0>>an>>q;
    //if(a0>an)swap(a0,an);
    while(q--){
        cin>>l>>r;
        ll sum=0;
        for(int i=l;i<=r;i++){
            sum+=a0+(an-a0)/n*i;
        }
        cout<<sum<<endl;
    }
    return 0;
}

H.
思路:模拟

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        double a,b,c;
        scanf("%lf%lf%lf",&a,&b,&c);
        double ans=a*c/b;
        double res=ans;
        for(int k=1;k<=3;k++){
            res*=10;
            int n=(int)res%10;
            if(k<3)continue;
            if(n<=4)break;
            else if(n>=6)break;
            else if(n==5){
                int m=(int)(res*1000000)%10;
                if(m!=0)ans-=0.005,ans+=0.01;
                else{
                    if(((int)(ans*100)%10)%2==1)ans-=0.005,ans+=0.01;
                    else ans-=0.005;
                }
            }
        }
        printf("%.2lf\n",ans);
    }
    return 0;
}

J.
思路:n<=9,直接枚举同分异构体数目就好

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int ans;
    if(n<4)ans=1;
    else if(n==4)ans=2;
    else if(n==5)ans=3;
    else if(n==6)ans=5;
    else if(n==7)ans=9;
    else if(n==8)ans=18;
    else if(n==9)ans=35;
    cout<<ans<<endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值