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; }
思路:由公式求出三边,保证三条边为整数,再判断三边是否构成三角形
#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