标签:others 面试 数字 就是 panel ack else view ott
http://acm.hdu.edu.cn/showproblem.php?pid=6468
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 470 Accepted Submission(s): 179
暴力模拟
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define eb emplace_back 8 #define maxn 100005 9 #define eps 1e-8 10 #define pi acos(-1.0) 11 #define rep(k,i,j) for(int k=i;k<j;k++) 12 typedef long long ll; 13 typedef pair<int,int> pii; 14 typedef pair<double,double>pdd; 15 typedef pair<int,char> pic; 16 typedef pair<pair<int,string>,pii> ppp; 17 typedef unsigned long long ull; 18 const long long mod=1e9+7; 19 const double oula=0.57721566490153286060651209; 20 using namespace std; 21 22 int n,k; 23 24 int main(){ 25 26 int t; 27 cin>>t; 28 while(t--){ 29 cin>>n>>k; 30 int ans=1; 31 k--; 32 while(k){ 33 if(ans*10<=n){ 34 ans*=10; 35 k--; 36 } 37 else{ 38 if(ans+1<=n){ 39 while(ans%10==9) ans/=10; 40 ans++; 41 k--; 42 } 43 else{ 44 ans/=10; 45 while(ans%10==9) ans/=10; 46 ans++; 47 k--; 48 } 49 } 50 } 51 cout<<ans<<endl; 52 } 53 54 }
标签:others 面试 数字 就是 panel ack else view ott
原文地址:https://www.cnblogs.com/Fighting-sh/p/10566060.html