#include<bits/stdc++.h> #include<algorithm> #define ll long long using namespace std; const ll nl=1e5+5; #define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int main(){ speed_up; ll x,y; cin>>x; cin>>y; if(x*log(y)>y*log(x)){ cout<<"<"<<endl; }else if(x*log(y)<y*log(x)){ cout<<">"<<endl; }else{ cout<<"="<<endl; } }
f题:按顺序找到满足si<sj<sk,计算最小花费,直接硬做会超时,要用到dp;
#include<bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f const int maxn=3005; int main(){
int n; int ans=INF; int val[maxn],cost[maxn],f[maxn][4]; cin>>n; for(int i=0;i<n;i++) cin>>val[i]; for(int i=0;i<n;i++) cin>>cost[i]; memset(f,INF,sizeof(f)); for (int i=0;i<n;i++) { f[i][0]=cost[i]; for (int j=0;j<i;j++) if (val[j]<val[i]) f[i][1]=min(f[i][1],f[j][0]+cost[i]); for (int j=0;j<i;j++) if (val[j]<val[i]) f[i][2]=min(f[i][2],f[j][1]+cost[i]); } for(int i=0;i<n;i++) ans=min(ans,f[i][2]); if(ans!=INF) cout<<ans<<endl; else cout<<-1<<endl; }