B3926 [GESP202312 三级] 单位转换 题解
根据题意,本题只有 k* 换 *,* 换 m* 或 k* 换 m* 三种情况。分类讨论即可。
具体见下面代码注释。
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;
while(n--){
int a;
string b,c;
cin>>a>>b>>c>>c>>c;
if(b.length()==1||c.length()==1){//* 换 m* 或 k* 换 *,都要 *1000
cout<<a<<" "<<b<<" = "<<a*1000<<" "<<c<<endl;
}else{//k* 换 m*,要 *1000000
cout<<a<<" "<<b<<" = "<<a*1000000<<" "<<c<<endl;
}
}
return 0;
}
楼上题解都写这么麻烦是干什么。