{"id":"eefe5699-ead5-432d-9678-9b16fd3fb609","name":"Any Base To Any Base","description":"1. You are given a number n.\r\n2. You are given a base b1. n is a number on base b.\r\n3. You are given another base b2.\r\n4. You are required to convert the number n of base b1 to a number in base b2.","inputFormat":"A number n\r\nA base b1\r\nA base b2","outputFormat":"A number of base b2 equal in value to n of base b1.","constraints":"0 &lt;= n &lt;= 512\r\n2 &lt;= b1 &lt;= 10\r\n2 &lt;= b2 &lt;= 10","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\npublic static int AnyToAny(int n, int b1, int b2){\r\n //write your code here\r\n}\r\nint main(){\r\n int n;\r\n int b1;\r\n int b2;\r\n cin >> n;\r\n cin >> b1;\r\n cin >> b2;\r\n int res = AnyToAny(n,b1,b2);\r\n cout << res <<endl;\r\n}"},"java":{"code":"import java.util.*;\r\n \r\n public class Main{\r\n \r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int sourceBase = scn.nextInt();\r\n int destBase= scn.nextInt();\r\n } \r\n }"},"python":{"code":"n = int(input())\r\nd1 = int(input())\r\nd2 = int(input())\r\n \r\ndef AnyToAny(n,d1,d2):\r\n # Write your code here\r\nif __name__ == \"__main__\": \r\n res = AnyToAny(n,d1,d2)\r\n print(res)"}},"points":10,"difficulty":"easy","sampleInput":"111001\r\n2\r\n3","sampleOutput":"2010","questionVideo":"https://www.youtube.com/embed/2-d3DcBFzug","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"b2815711-9973-4d9b-a773-ae47071fba03","name":"Any Base To Any Base","slug":"any-base-to-any-base","type":1}],"next":{"id":"3c8963b8-9f78-40fb-a8a8-1119dae5d642","name":"Any Base To Any Base","type":3,"slug":"any-base-to-any-base"},"prev":{"id":"7a7af2c1-6171-479a-be94-bb4af94e4009","name":"Any base to Decimal","type":3,"slug":"any-base-to-decimal"}}}

Any Base To Any Base

1. You are given a number n. 2. You are given a base b1. n is a number on base b. 3. You are given another base b2. 4. You are required to convert the number n of base b1 to a number in base b2.

{"id":"eefe5699-ead5-432d-9678-9b16fd3fb609","name":"Any Base To Any Base","description":"1. You are given a number n.\r\n2. You are given a base b1. n is a number on base b.\r\n3. You are given another base b2.\r\n4. You are required to convert the number n of base b1 to a number in base b2.","inputFormat":"A number n\r\nA base b1\r\nA base b2","outputFormat":"A number of base b2 equal in value to n of base b1.","constraints":"0 &lt;= n &lt;= 512\r\n2 &lt;= b1 &lt;= 10\r\n2 &lt;= b2 &lt;= 10","sampleCode":{"cpp":{"code":"#include<iostream>\r\nusing namespace std;\r\npublic static int AnyToAny(int n, int b1, int b2){\r\n //write your code here\r\n}\r\nint main(){\r\n int n;\r\n int b1;\r\n int b2;\r\n cin >> n;\r\n cin >> b1;\r\n cin >> b2;\r\n int res = AnyToAny(n,b1,b2);\r\n cout << res <<endl;\r\n}"},"java":{"code":"import java.util.*;\r\n \r\n public class Main{\r\n \r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int sourceBase = scn.nextInt();\r\n int destBase= scn.nextInt();\r\n } \r\n }"},"python":{"code":"n = int(input())\r\nd1 = int(input())\r\nd2 = int(input())\r\n \r\ndef AnyToAny(n,d1,d2):\r\n # Write your code here\r\nif __name__ == \"__main__\": \r\n res = AnyToAny(n,d1,d2)\r\n print(res)"}},"points":10,"difficulty":"easy","sampleInput":"111001\r\n2\r\n3","sampleOutput":"2010","questionVideo":"https://www.youtube.com/embed/2-d3DcBFzug","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"f10b54f1-0f44-408f-82d5-89c189f4ad57","name":"Function and Arrays","slug":"function-and-arrays","type":0},{"id":"b2815711-9973-4d9b-a773-ae47071fba03","name":"Any Base To Any Base","slug":"any-base-to-any-base","type":1}],"next":{"id":"3c8963b8-9f78-40fb-a8a8-1119dae5d642","name":"Any Base To Any Base","type":3,"slug":"any-base-to-any-base"},"prev":{"id":"7a7af2c1-6171-479a-be94-bb4af94e4009","name":"Any base to Decimal","type":3,"slug":"any-base-to-decimal"}}}
plane

Editor


Loading...

Any Base To Any Base

easy

1. You are given a number n. 2. You are given a base b1. n is a number on base b. 3. You are given another base b2. 4. You are required to convert the number n of base b1 to a number in base b2.

Constraints

0 <= n <= 512 2 <= b1 <= 10 2 <= b2 <= 10

Format

Input

A number n A base b1 A base b2

Output

A number of base b2 equal in value to n of base b1.

Example

Sample Input

111001 2 3

Sample Output

2010

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode