5.10快手笔试题解
第一题:输出汉字形式的数字。
方便测试写的比较乱,基本上就是个小模拟题。
#include <iostream> #include<bits/stdc++.h> using namespace std; //kuaishou //A char Big[10]="WQBSL"; int Shu[10]={10000,1000,100,10,1}; int ans[10]; int main() { int a=1; while(a--){ string str=""; memset(ans,0,sizeof ans); int A,AA; cin>>A; AA=A; bool First=true,OUT=true; for(int i=0;i<5;i++){ ans[i]=AA/Shu[i]; AA=AA%Shu[i]; } for(int i=0;i<5;i++){ if(ans[i]==0){ if(First) continue; else { if(str[str.size()-1]!='L') str+="L"; } }else{ OUT=false; First=false; str+=(ans[i]+'0'); if(i<4) str+=Big[i]; } } if(OUT) cout<<"L"<<endl; else { if(str.size()>1&&str[str.size()-1]=='L') str=str.substr(0,str.size()-1); cout<<str<<endl; } } return 0; }
第二题:博弈取石头
假博弈,真找规律
//B int main() { int T; cin>>T; while(T--) { int N; cin>>N; if(N%3!=0) cout<<"lucky"<<endl; else cout<<"don't be discouraged"<<endl; } return 0; }
第三题:放盒子
乱搞暴力
#include <iostream> #include<bits/stdc++.h> using namespace std; //C struct Box{ int A,K; }box[100005]; bool cmp(Box a,Box b){ return a.K<b.K; } int main() { int T; cin>>T; while(T--){ int N; cin>>N; for(int i=0;i<N;i++) { cin>>box[i].K>>box[i].A; } sort(box,box+N,cmp); long long P=box[N-1].K; for(int i=N-1;i>=0;i--){ int x=sqrt(box[i].A*1.0)-1; while(x*x<box[i].A){ x++; } int cnt=1; while((1<<cnt)<x){ cnt++; } if(P<cnt+box[i].K){ P=cnt+box[i].K; } } cout<<P<<endl; } return 0; }基本上就是这样。题目很吓人,其实很水#春招##笔试题目##实习#