{"id":"ed38bd69-20b3-417e-ad57-f0c778e5dba2","name":"Powerful Number","description":"1. You are given three numbers A, B, and X.\r\n2. You have to print all-powerful numbers that have value less than or equal to X.\r\n3. A number is powerful if it is equal to x^i + y^j for i >= 0 and j >= 0.","inputFormat":"Three numbers A, B, and X.","outputFormat":"Space-separated integers representing powerful numbers.","constraints":"1 &lt;= A,B &lt;= 100\r\n1 &lt;= X &lt;= 10^6","sampleCode":{"cpp":{"code":"#include <iostream>\r\n#include <vector>\r\n#include <unordered_set>\r\n\r\nusing namespace std;\r\n\r\nvector<int> powerfulNumbers(int x, int y, int bound)\r\n{\r\n return {};\r\n}\r\n\r\nint main()\r\n{\r\n int a, b, x;\r\n cin >> a >> b >> x;\r\n vector<int> ans = powerfulNumbers(a, b, x);\r\n for (int ele : ans)\r\n cout << ele << \" \";\r\n\r\n return 0;\r\n}\r\n"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\t\r\n\tpublic static ArrayList<Integer> powerfulIntegers(int x, int y, int bound) {\r\n\t\t// write your code here\r\n\r\n\t\treturn null;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint x = scn.nextInt();\r\n\t\tint y = scn.nextInt();\r\n\t\tint bound = scn.nextInt();\r\n\t\tArrayList<Integer> ret = new ArrayList<>();\r\n\t\tret = powerfulIntegers(x, y, bound);\r\n\t\tCollections.sort(ret);\r\n\t\tfor (int i = 0; i < ret.size(); i++) {\r\n\t\t\tSystem.out.print(ret.get(i) + \" \");\r\n\t\t}\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"","sampleOutput":"","questionVideo":"","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":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"26b94b6b-5595-42eb-a6bc-4612226299fe","name":"Powerful Number","slug":"powerful-number","type":1}],"next":{"id":"881ce221-3af8-48ef-b70f-927917570258","name":"Powerful Number MCQ","type":0,"slug":"powerful-number-mcq"},"prev":{"id":"112bd34a-52bc-4475-809d-4b0f8de39b54","name":"Quadruplet Sum - 2","type":3,"slug":"quadruplet-sum-2"}}}

Powerful Number

1. You are given three numbers A, B, and X. 2. You have to print all-powerful numbers that have value less than or equal to X. 3. A number is powerful if it is equal to x^i + y^j for i >= 0 and j >= 0.

{"id":"ed38bd69-20b3-417e-ad57-f0c778e5dba2","name":"Powerful Number","description":"1. You are given three numbers A, B, and X.\r\n2. You have to print all-powerful numbers that have value less than or equal to X.\r\n3. A number is powerful if it is equal to x^i + y^j for i >= 0 and j >= 0.","inputFormat":"Three numbers A, B, and X.","outputFormat":"Space-separated integers representing powerful numbers.","constraints":"1 &lt;= A,B &lt;= 100\r\n1 &lt;= X &lt;= 10^6","sampleCode":{"cpp":{"code":"#include <iostream>\r\n#include <vector>\r\n#include <unordered_set>\r\n\r\nusing namespace std;\r\n\r\nvector<int> powerfulNumbers(int x, int y, int bound)\r\n{\r\n return {};\r\n}\r\n\r\nint main()\r\n{\r\n int a, b, x;\r\n cin >> a >> b >> x;\r\n vector<int> ans = powerfulNumbers(a, b, x);\r\n for (int ele : ans)\r\n cout << ele << \" \";\r\n\r\n return 0;\r\n}\r\n"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\t\r\n\tpublic static ArrayList<Integer> powerfulIntegers(int x, int y, int bound) {\r\n\t\t// write your code here\r\n\r\n\t\treturn null;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint x = scn.nextInt();\r\n\t\tint y = scn.nextInt();\r\n\t\tint bound = scn.nextInt();\r\n\t\tArrayList<Integer> ret = new ArrayList<>();\r\n\t\tret = powerfulIntegers(x, y, bound);\r\n\t\tCollections.sort(ret);\r\n\t\tfor (int i = 0; i < ret.size(); i++) {\r\n\t\t\tSystem.out.print(ret.get(i) + \" \");\r\n\t\t}\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"","sampleOutput":"","questionVideo":"","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":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"26b94b6b-5595-42eb-a6bc-4612226299fe","name":"Powerful Number","slug":"powerful-number","type":1}],"next":{"id":"881ce221-3af8-48ef-b70f-927917570258","name":"Powerful Number MCQ","type":0,"slug":"powerful-number-mcq"},"prev":{"id":"112bd34a-52bc-4475-809d-4b0f8de39b54","name":"Quadruplet Sum - 2","type":3,"slug":"quadruplet-sum-2"}}}
plane

Editor


Loading...

Powerful Number

easy

1. You are given three numbers A, B, and X. 2. You have to print all-powerful numbers that have value less than or equal to X. 3. A number is powerful if it is equal to x^i + y^j for i >= 0 and j >= 0.

Constraints

1 <= A,B <= 100 1 <= X <= 10^6

Format

Input

Three numbers A, B, and X.

Output

Space-separated integers representing powerful numbers.

Example

Sample Output

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode