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;
- using System.Threading.Tasks;
- namespace mainSolution
- {
- public class MyException : Exception
- {
- public MyException(string messege) : base(message: messege + "\n\n\n Exception founded by Decibit\n\n\n") { }
- public MyException() : base()
- {
- }
- public void Messsage()
- {
- Console.WriteLine("\n\n\n\n\n\n Invalid number, please enter a number from 1 to 12 \n\n\n\n\n\n");
- }
- }
- class Input
- {
- private static IEnumerator<string> getin()
- {
- while (true)
- foreach (string s in Console.ReadLine().Split().Where(x => x.Length > 0))
- yield return s;
- }
- private IEnumerator<string> inp = getin();
- public string GetString() { inp.MoveNext(); return inp.Current; }
- public int GetInt() { return int.Parse(GetString()); }
- public long GetLong() { return long.Parse(GetString()); }
- public double GetDouble() { return double.Parse(GetString()); }
- }
- static class Program
- {
- static public Input cin = new Input();
- static double getSqrt(double a, double n, double e = 1e-10)
- {
- double x0 = a / n;
- double x = ((n - 1) * x0 + a / Math.Pow(x0, n - 1)) / n;
- while (Math.Abs(x0 - x) >= e)
- {
- x0 = x;
- x = ((n - 1) * x0 + a / Math.Pow(x0, n - 1)) / n;
- }
- return x;
- }
- static void Main(string[] args)
- {
- double a = cin.GetDouble();
- int A = Convert.ToInt32(Math.Ceiling(a));
- double save_a = a;
- double b = cin.GetDouble();
- int B = Convert.ToInt32(b);
- double h = cin.GetDouble();
- double ans = 0;
- for (int i = 1; a <= b; ++i)
- {
- Console.WriteLine($"sqrt[i] = {getSqrt(a, i)}");
- ans += getSqrt(a, i);
- a += h;
- }
- Console.WriteLine($"sum = {ans}");
- for (int x = A; x <= B - 2; x++)
- for (int y = x + 1; y <= B - 1; y++)
- for (int z = y + 1; z <= B; z++)
- {
- if (x + y == z)
- {
- Console.WriteLine($"x = {x}, y = {y}, z = {z}");
- }
- }
- if (save_a < 2)
- Console.WriteLine("No solution");
- else
- Console.WriteLine("n = 1");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement