結果
| 問題 | No.816 Beautiful tuples | 
| コンテスト | |
| ユーザー |  ひばち | 
| 提出日時 | 2019-04-26 22:44:29 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 29 ms / 1,500 ms | 
| コード長 | 1,716 bytes | 
| コンパイル時間 | 1,066 ms | 
| コンパイル使用メモリ | 114,040 KB | 
| 実行使用メモリ | 27,184 KB | 
| 最終ジャッジ日時 | 2024-11-25 05:19:48 | 
| 合計ジャッジ時間 | 2,281 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 15 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
class Program
{
    static void Main(string[] args)
    {
        //Solve();
        WriteLine(Solve());
    }
    static int Solve()
    {
        var ab = Input.ar;
        var list = new List<int>();
        for(var i=1;i*i<=ab[0]+ab[1];i++)
            if ((ab[0] + ab[1]) % i == 0)
            {
                list.Add(i);
                list.Add((ab[0] + ab[1]) / i);
            }
        list = list.OrderBy(v => v).ToList();
        foreach (var val in list)
        {
            if (ab[0] == val || ab[1] == val) continue;
            if ((ab[0] + val) % ab[1] == 0 && (ab[1] + val) % ab[0] == 0)
                return val;
        }
        return -1;
    }
}
public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}
            
            
            
        