jiangmuran @ 2022-07-28 17:02:33
RT,
#include <iostream>
using namespace std;
#define int long long
string zhe_dao_ti_you_wen_ti(int NZYWT)
{
int tmd=NZYWT;
string s;
while (tmd>0)
{
s+=tmd%10+'0';
tmd/=10;
}
for (int i=0;i<s.size()/2;i++)
{
swap(s[i],s[s.size()-1-i]);
}
return s;
}
int zhedaotichutirenjiushizaizhemowomen(string shaderdsac)
{
int ret=0;
for (int i=0;i<shaderdsac.size();i++)
{
ret=ret*10+shaderdsac[i]-'0';
}
return ret;
}
string js(int a,int b,char op)
{
int c;
if (op == 'a')
{
op='+';
c=a+b;
}
if (op == 'b')
{
op='-';
c=a-b;
}
if (op == 'c')
{
op='*';
c=a*b;
}
return zhe_dao_ti_you_wen_ti(a)+op+zhe_dao_ti_you_wen_ti(b)+'='+zhe_dao_ti_you_wen_ti(c);
}
signed main()
{
int n;
cin >> n;
char c;
int a,b;
for(int i=0;i<n;i++)
{
string tmp;
cin >> tmp;
if (tmp[0] >= '0' && tmp[0] <= '9')
{
a = zhedaotichutirenjiushizaizhemowomen(tmp);
cin >> b;
}
else
{
c=tmp[0];
cin >> a >> b;
}
cout << js(a,b,c) << endl;
cout << js(a,b,c).size() << endl;
}
}
(我绝对不会告诉你码风比较乱是因为我写这道题的时候抓狂了
我疯了
by jiangmuran @ 2022-07-29 21:23:58
zzzz
by CBC18 @ 2022-08-11 13:50:22
我也是20分
by CBC18 @ 2022-08-11 13:51:50
#include<bits/stdc++.h>
using namespace std;
struct lis{
string s;
int a,b;
};
int main(){
int i;
char str=' ';
scanf("%d",&i);
lis arr[i];
for(int j=0;j<i;j++){
cin>>arr[j].s>>arr[j].a>>arr[j].b;
if((arr[j].s[0]>='a'&&arr[j].s[0]<='c')==false){
arr[j].b=arr[j].a;
arr[j].a=0;
for(int k=0,o=arr[i].s.length();k<arr[j].s.length();k++,o--){
arr[j].a=+(arr[j].s[k]-'0')*o;
}
arr[j].s[0]=str;
}else{
str=arr[j].s[0];
}
}
for(int j=0;j<i;j++){
int sum=0,as=arr[j].a,bs=arr[j].b;
if(arr[j].s[0]=='a'){
int x=arr[j].a+arr[j].b,x2=arr[j].a-arr[j].b;
cout<<arr[j].a<<'+'<<arr[j].b<<'='<<arr[j].a+arr[j].b<<endl;
while(as){
as/=10;
sum++;
}
while(bs){
bs/=10;
sum++;
}
while(x){
x/=10;
sum++;
}
sum+=2;
if(x2<0) sum++;
cout<<sum<<endl;
}else if(arr[j].s[0]=='b'){
int x=arr[j].a-arr[j].b,x2=arr[j].a-arr[j].b;
cout<<arr[j].a<<'-'<<arr[j].b<<'='<<arr[j].a-arr[j].b<<endl;
while(as){
as/=10;
sum++;
}
while(bs){
bs/=10;
sum++;
}
while(x){
x/=10;
sum++;
}
sum+=2;
if(x2<0) sum++;
cout<<sum<<endl;
}else if(arr[j].s[0]=='c'){
int x=arr[j].a*arr[j].b,x2=arr[j].a-arr[j].b;
cout<<arr[j].a<<'*'<<arr[j].b<<'='<<arr[j].a*arr[j].b<<endl;
while(as){
as/=10;
sum++;
}
while(bs){
bs/=10;
sum++;
}
while(x){
x/=10;
sum++;
}
sum+=2;
if(x2<0) sum++;
cout<<sum<<endl;
}
}
return 0;
}
我也疯了