2 solutions

  • 0
    @ 2026-2-22 12:33:47
    #include<bits/stdc++.h>
    #include<sstream>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        //string a[1005]={};
        for(int i=0;i<n;i++)
        {
            int b;
            cin>>b;
            string c1,c2;
            cin>>c1;
            char d;
            cin>>d;
            cin>>d;
            cin>>c2;
            cout<<b<<" "<<c1<<" = ";
            if(c1=="m"&&c2=="mm")
            {
                cout<<b*1000;
            }
            else if(c1=="km"&&c2=="mm")
            {
                cout<<b*1000000;
            }
            else if(c1=="km"&&c2=="m")
            {
                cout<<b*1000;
            }
            else if(c1=="g"&&c2=="mg")
            {
                cout<<b*1000;
            }
            else if(c1=="kg"&&c2=="mg")
            {
                cout<<b*1000000;
            }
            else if(c1=="kg"&&c2=="g")
            {
                cout<<b*1000;
            }
            cout<<" "<<c2<<"\n";
        }
    }
    

    Information

    ID
    48
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    8
    Accepted
    5
    Uploaded By