Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- class Program
- {
- static void cubes(ushort n, out ushort a, out ushort b)
- {
- a = 1029;
- b = 1029;
- double mu = 1.0 / 3;
- bool exist = false;
- ushort border = (ushort)((int)Math.Pow(n, mu) + 1);
- for (ushort i = 0; i < border; i++) {
- for (ushort j = 0; j < border; j++) {
- if ((ushort)((int)Math.Pow(i, 3) + (int)Math.Pow(j, 3)) == n)
- {
- a = i;
- b = j;
- exist = true;
- break;
- }
- }
- }
- }
- static void Main()
- {
- ushort n;
- string input = Console.ReadLine();
- if (!ushort.TryParse(input, out n))
- {
- Console.WriteLine("wrong");
- }
- else {
- ushort a, b;
- cubes(n, out a, out b);
- Console.WriteLine(a == 1029 ? "impossible" : $"{a} {b}");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement