首页 > 其他分享 >week5

week5

时间:2023-01-30 21:23:36浏览次数:73  
标签:int pow ll cin long main week5

Day1

2023牛客寒假算法基础集训营4

A—清楚姐姐学信息论

思路:比较pow(x, y)和pow(y, x)大小

#include <bits/stdc++.h>
using namespace std;

int main() {
    long long int a, g,n;
    cin >> a >> g;
   
    if (pow(a,g) <pow(g,a)) {
        cout << g << endl;
    } else if (pow(a,g) > pow(g,a)) {
        cout << a <<endl;
    }
    else cout<< min(a,g)<<endl;
    return 0;
}

 

E—清楚姐姐打怪升级

思路:若在一次时间间隔内的恢复量大于等于攻击力则杀不死

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,M=1e9;
typedef long long ll;
ll n,t,a,h,v,s=1;
int main(){
    cin>>n>>t>>a;
    bool ok=true;
    for(int i=0;i<n;++i){
        cin>>h>>v;
        h-=a,s+=t;
        if(h<=0)continue;
        if(t*v>=a){
            cout<<"-1";return 0;
        }
        else{
            s+=(h/(a-v*t))*t;
            if(h%(a-v*t))s+=t;
        }
    }
    cout<<s-t;
    return 0;
}

 

 L—清楚姐姐的三角形I

 思路:由公式求出三边,保证三条边为整数,再判断三边是否构成三角形

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,M=1e9;
int t;
typedef long long ll;
int main(){
    cin>>t;
    ll a,b,c,aa,bb,cc;
    while(t--){
        bool ok=true;
        cin>>a>>b>>c;
        if((a+c-b)%2||(b+c-a)%2||(a+b-c)%2)ok=false;
        else{
            bb=(a+c-b)/2;
            aa=(b+c-a)/2;
            cc=(a+b-c)/2;
        }
        if(!ok||((aa+bb)<=cc||(bb+cc)<=aa||(aa+cc)<=bb))cout<<"No\n";
        else {
            cout<<"Yes\n";
            cout<<aa<<' '<<bb<<' '<<cc<<'\n';
        }
    }
    return 0;
}

 


M—清楚姐姐的三角形II 思路:循环11212...
#include <iostream>
using namespace std;

int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        if((i+1)%3!=0){
            cout<<"1";
        }else{
            cout<<"2";
        }
        if(i!=n-1){
            cout<<" ";
        }
    }
}

 

 

标签:int,pow,ll,cin,long,main,week5
From: https://www.cnblogs.com/bible-/p/17077094.html

相关文章

  • ACM预备队-week5(DFS/BFS/二分图)
    [蓝桥杯2013国C]危险系数题目链接:P8604[蓝桥杯2013国C]危险系数-洛谷|计算机科学教育新生态(luogu.com.cn)割点:删除这个顶点集合以所有顶点相关联的边以......
  • 计算机结构--week5
    内存特征:  计算机中的内存: Capacity:Thecapacityofthememoryisthenumberofbytes(orpreferablywords)itcanstore. Thewordsize(orlength)......
  • Week5-Technology: Internets and Packets
    Week5-Technology:InternetsandPacketsCommonLinkLayertechnologiesare…WiFiOpticalSatelliteEthernetCableModemDSL**Whenlookingataddressesf......
  • 学校Java Week5
    Week5W5L1ReviewControlFlowConditionLoopscounterLoopsForloopsDoestheexactsamethingwithlesscodefor(inti=0;i<10;i++)//initialvalue......
  • week5
    week4完成作业:自定义写出10个定时任务的示例:比如每周三凌晨三点执行data命令要求尽量的覆盖各种场景\2.图文并茂说明Linux进程和内存概念\3.图文并茂说明Linux......