標籤:its col eof tmp clu sort ++ 技術分享 --
題目連結:https://nanti.jisuanke.com/t/27644
題目大意:
解題思路:
代碼:
1 #include<bits/stdc++.h> 2 #define lc(a) (a<<1) 3 #define rc(a) (a<<1|1) 4 #define MID(a,b) ((a+b)>>1) 5 #define fin(name) freopen(name,"r",stdin) 6 #define fout(name) freopen(name,"w",stdout) 7 #define clr(arr,val) memset(arr,val,sizeof(arr)) 8 #define _for(i,start,end) for(int i=start;i<=end;i++) 9 #define FAST_IO ios::sync_with_stdio(false);cin.tie(0);10 using namespace std;11 typedef long long LL;12 const int N=1e5+5;13 const int INF=0x3f3f3f3f;14 const double eps=1e-10;15 16 struct node{17 int a,b;18 }p[N];19 20 bool cmp(node x,node y){21 return x.a*y.b+x.b>y.a*x.b+y.b;22 }23 24 int main(){25 FAST_IO;26 int T;27 cin>>T;28 while(T--){29 int n,x;30 cin>>n>>x;31 for(int i=1;i<=n;i++){32 cin>>p[i].a;33 }34 for(int i=1;i<=n;i++){35 cin>>p[i].b;36 }37 sort(p+1,p+1+n,cmp);38 int ans=0,tmp=1;39 for(int i=1;i<=n;i++){40 ans=(ans+tmp*p[i].b)%10;41 tmp=tmp*p[i].a%10;42 }43 ans=(ans+tmp*x)%10;44 cout<<ans<<endl;45 }46 return 0;47 }
計蒜客 貝殼找房函數最值(好題,巧妙排序)