結果
| 問題 |
No.937 Ultra Sword
|
| コンテスト | |
| ユーザー |
keymoon
|
| 提出日時 | 2019-11-29 22:01:41 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,232 bytes |
| コンパイル時間 | 4,404 ms |
| コンパイル使用メモリ | 114,132 KB |
| 実行使用メモリ | 44,680 KB |
| 最終ジャッジ日時 | 2024-11-21 02:19:06 |
| 合計ジャッジ時間 | 19,706 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 23 |
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
public static void Main()
{
int n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] sum = new long[100001];
for (int i = 0; i < n; i++)
foreach (var div in Divisors(a[i]).Distinct())
sum[div] += a[i] - (a[i] / div);
for (int i = 1; ; i <<= 1)
{
if (a.Any(x => (x & i) != 0))
{
Console.WriteLine(a.Sum() - sum.Where((_, ind) => (ind & (i - 1)) == 0).Max());
return;
}
}
}
static IEnumerable<long> Divisors(long n)
{
var max = (int)Ceiling(Sqrt(n));
for (int i = 1; i <= max; i++)
if (n % i == 0) { yield return i; yield return n / i; }
}
}
keymoon