結果

問題 No.1198 お菓子配り-1
ユーザー Lily89164763Lily89164763
提出日時 2020-08-28 21:37:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 2,450 bytes
コンパイル時間 2,284 ms
コンパイル使用メモリ 115,220 KB
実行使用メモリ 25,820 KB
最終ジャッジ日時 2024-04-28 01:24:13
合計ジャッジ時間 3,477 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
25,692 KB
testcase_01 AC 24 ms
21,560 KB
testcase_02 AC 25 ms
23,724 KB
testcase_03 AC 24 ms
23,652 KB
testcase_04 AC 24 ms
21,432 KB
testcase_05 AC 25 ms
23,524 KB
testcase_06 AC 25 ms
21,680 KB
testcase_07 AC 25 ms
23,560 KB
testcase_08 AC 25 ms
25,692 KB
testcase_09 AC 24 ms
23,348 KB
testcase_10 AC 26 ms
23,524 KB
testcase_11 AC 26 ms
25,820 KB
testcase_12 AC 25 ms
23,824 KB
testcase_13 AC 26 ms
23,656 KB
testcase_14 AC 25 ms
23,656 KB
testcase_15 AC 25 ms
23,700 KB
testcase_16 AC 25 ms
25,816 KB
testcase_17 AC 25 ms
25,728 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Numerics;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();

        // (a + b) (a - b) = N

        // (a+b)(a-b)の偶奇一致
        // 素因数2が1つじゃない

        // a,bが正
        // (a+b) + (a-b)
        // (a+b) - (a-b)が正



        string n = sc.Next();
        if (n == "1" || n == "4")
        {
            Console.WriteLine("-1");
            return;
        }
        int m = 0;
        foreach (var c in n)
        {
            m *= 10;
            m += c - '0';
            m %= 4;
        }

        Console.WriteLine(m == 2 ? "-1" : "1");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}
0