西南民族大学 2023 天梯自主训练 4
思路:a表示被除多项式,b表示除数多项式,一次运算的商的项p为a的最高项-b的最高项,商的系数q为a的最高项的系数除以b的最高项的系数,将所有a中项数和b的项数乘p后相同的系数减去b项的系数乘q(...haoluan...看图吧)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; typedef pair<string,int>PSI; const int N=1e5+5,INF=0x3f3f3f3f,Mod=1e6; const double eps=1e-6; typedef long long ll; int n,m; double a[N],b[N],c[N]; void P(double x[],int y){ int cnt=0; for(int i=0;i<=y;++i){ if(abs(x[i])>=0.1)cnt++; } cout<<cnt; if(!cnt)cout<<" 0 0.0"; else{ for(int i=y;i>=0;--i){ if(abs(x[i])>=0.1)cout<<' '<<i<<' '<<fixed<<setprecision(1)<<x[i]; } } } int main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int idx1,idx2; cin>>n; for(int i=0,x;i<n;++i){ cin>>x; cin>>a[x]; if(i==0)idx1=x; } cin>>m; for(int i=0,x;i<m;++i){ cin>>x; cin>>b[x]; if(i==0)idx2=x; } int ma=idx1-idx2; while(idx1>=idx2){ int p=idx1-idx2; double q=a[idx1]/b[idx2]; c[p]=q; for(int i=idx2;i>=0;--i){ a[i+p]-=b[i]*q; } while(a[idx1]==0)idx1--; } P(c,ma);cout<<'\n'; P(a,idx1); return 0; }View Code
思路:物理题...分解下速度,vy=gt,s=vxt,E=mv2/2,vy=vsinθ,vx=vcosθ,一次起点到落地的距离x=2*s=2v2sinθvcosθ/g=v2sin2θ/g,当θ为90度时x最大,由于v2=2E/m,每次改变v2即可
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; typedef pair<string,int>PSI; const int N=1e5+5,INF=0x3f3f3f3f,Mod=1e6; const double eps=1e-8; typedef long long ll; double w,p,v2,s,g=9.8; int main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>w>>p; v2=1000*2*100/w; while(v2>eps){ s+=v2/g; v2*=(1-p/100); } cout<<fixed<<setprecision(3)<<s; return 0; }View Code
标签:typedef,自主,int,double,v2,天梯,2023,idx2,idx1 From: https://www.cnblogs.com/bible-/p/17338134.html