結果

問題 No.1113 二つの整数 / Two Integers
ユーザー Lily89164763
提出日時 2020-07-17 21:22:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 1,000 ms
コード長 5,499 bytes
コンパイル時間 2,893 ms
コンパイル使用メモリ 112,512 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-11-30 06:20:09
合計ジャッジ時間 4,063 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
プレゼンテーションモードにする

using System;
using CompLib.Mathematics;
using CompLib.Util;
public class Program
{
public void Solve()
{
var sc = new Scanner();
long a = sc.NextLong();
long b = sc.NextLong();
long gcd = MathEx.GCD(a, b);
long ng = 0;
long ok = 1000000000;
while (ok - ng > 1)
{
long mid = (ok + ng) / 2;
if (mid * mid >= gcd) ok = mid;
else ng = mid;
}
if (ok * ok == gcd)
{
Console.WriteLine("Odd");
}
else
{
Console.WriteLine("Even");
}
}
public static void Main(string[] args) => new Program().Solve();
}
// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
using System;
using System.Collections.Generic;
#region GCD LCM
/// <summary>
///
/// </summary>
public static partial class MathEx
{
/// <summary>
/// 2
/// </summary>
/// <param name="n"></param>
/// <param name="m">2 </param>
/// <returns>2 </returns>
/// <remarks> O(log N) </remarks>
public static int GCD(int n, int m)
{
return (int) GCD((long) n, m);
}
/// <summary>
/// 2
/// </summary>
/// <param name="n"></param>
/// <param name="m">2 </param>
/// <returns>2 </returns>
/// <remarks> O(log N) </remarks>
public static long GCD(long n, long m)
{
n = Math.Abs(n);
m = Math.Abs(m);
while (n != 0)
{
m %= n;
if (m == 0) return n;
n %= m;
}
return m;
}
/// <summary>
/// 2
/// </summary>
/// <param name="n"></param>
/// <param name="m">2 </param>
/// <returns>2 </returns>
/// <remarks> O(log N) </remarks>
public static long LCM(long n, long m)
{
return (n / GCD(n, m)) * m;
}
}
#endregion
#region PrimeSieve
public static partial class MathEx
{
/// <summary>
///
/// </summary>
/// <param name="max"></param>
/// <param name="primes"></param>
/// <returns>0 max </returns>
/// <remarks> O(N loglog N) </remarks>
public static bool[] Sieve(int max, List<int> primes = null)
{
var isPrime = new bool[max + 1];
for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
for (int i = 2; i * i <= max; i++)
if (!isPrime[i]) continue;
else
for (int j = i * i; j <= max; j += i)
isPrime[j] = false;
if (primes != null)
for (int i = 0; i <= max; i++)
if (isPrime[i])
primes.Add(i);
return isPrime;
}
}
#endregion
}
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();
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0