Пример #1
0
        public static void Solve(Stream stdin, Stream stdout)
        {
            IScanner scanner = new OptimizedPositiveIntReader(stdin);
            // uncomment when you need more advanced reader
            scanner = new Scanner(stdin);
            // scanner = new LineReader(stdin);
            var writer = new BufferedStdoutWriter(stdout);

            var numberOfTestCases = scanner.NextInt();

            for (var i = 0; i < numberOfTestCases; i++)
            {
                BigInteger x1 = scanner.NextInt();
                BigInteger y1 = scanner.NextInt();
                var operation = scanner.Next();
                BigInteger x2 = scanner.NextInt();
                BigInteger y2 = scanner.NextInt();

                Tuple<BigInteger, BigInteger> result;
                switch (operation)
                {
                    case "+":
                        result = Add(x1, y1, x2, y2);
                        break;
                    case "-":
                        // to substract is like to add but with the oposite sign
                        result = Add(x1, y1, -x2, y2);
                        break;
                    case "*":
                        result = Multiply(x1, y1, x2, y2);
                        break;
                    case "/":
                        // to divide is like to multiple by the oposite
                        result = Multiply(x1, y1, y2, x2);
                        break;
                    default:
                        throw new InvalidOperationException("no operation for:" + operation);
                }
                writer.Write(result.Item1);
                writer.Write(" / ");
                writer.Write(result.Item2);
                writer.Write("\n");
            }

            writer.Flush();
        }
        public static void Solve(Stream stdin, Stream stdout)
        {
            IScanner scanner = new OptimizedPositiveIntReader(stdin);
            // uncomment when you need more advanced reader
            scanner = new Scanner(stdin);
            // scanner = new LineReader(stdin);
            var writer = new BufferedStdoutWriter(stdout);

            // radius
            float r;
            // marked
            int m;
            // circle
            int c;

            while (true)
            {
                r = scanner.NextFloat();
                m = scanner.NextInt();
                c = scanner.NextInt();

                if (m == 0 && c == 0)
                    break;

                var circleSize = Math.PI * r * r;

                var estimatedSize = (c * 2 * r * 2 * r) / (float)m;

                writer.Write(circleSize.ToString(CultureInfo.InvariantCulture));
                //                writer.Write(circleSize.ToString(CultureInfo.InvariantCulture));
                writer.Write(" ");
                writer.Write(estimatedSize.ToString(CultureInfo.InvariantCulture));
                //                writer.Write(estimatedSize.ToString(CultureInfo.InvariantCulture));
                writer.Write("\n");
            }

            writer.Flush();
        }
Пример #3
0
        public static void Solve(Stream stdin, Stream stdout)
        {
            IScanner scanner = new OptimizedIntReader(stdin);
            // uncomment when you need more advanced reader
            scanner = new Scanner(stdin);
            BufferedStdoutWriter writer = new BufferedStdoutWriter(stdout);

            var size = scanner.NextInt();

            Point[] points = new Point[size];

            for (int i = 0; i < size; i++)
            {
                points[i] = new Point(scanner.NextInt(), scanner.NextInt());
            }

            //    var result = OldSolution.Solve(points);
            var result = Solve(ref points);

            writer.Write(result);
            writer.Write("\n");
            writer.Flush();
        }