Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int arr[7] = {1,10,100,1000,10000,100000,10000000};
- int main() {
- int cases; scanf("%d",&cases);
- while(cases--)
- {
- double num; string unit1,unit2;
- scanf("%d",&num); cin>>unit1>>unit2;
- int eq,eq2;
- if(unit1=="km") eq=0;
- else if(unit1=="hm") eq=1;
- else if(unit1=="Dm") eq=2;
- else if(unit1=="m") eq=3;
- else if(unit1=="dm") eq=4;
- else if(unit1=="cm") eq=5;
- else if(unit1=="mm") eq=6;
- if(unit2=="km") eq2=0;
- else if(unit2=="hm") eq2=1;
- else if(unit2=="Dm") eq2=2;
- else if(unit2=="m") eq2=3;
- else if(unit2=="dm") eq2=4;
- else if(unit2=="cm") eq2=5;
- else if(unit2=="mm") eq2=6;
- double sol;
- if(eq>eq2) sol=num*(arr[eq]-arr[eq2]);
- else if(eq<eq2) sol=num/(arr[eq2]-arr[eq]);
- printf("%llf\n",sol);
- }
- return 0;
- }
- /**
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- cout<<"Hello World";
- return 0;
- }
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- cout<<"Hello World";
- return 0;
- }
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- cout<<"Hello World";
- return 0;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement