結果
| 問題 | No.189 SUPER HAPPY DAY |
| コンテスト | |
| ユーザー |
紙ぺーぱー
|
| 提出日時 | 2015-04-18 02:57:45 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,364 bytes |
| 記録 | |
| コンパイル時間 | 2,343 ms |
| コンパイル使用メモリ | 113,088 KB |
| 実行使用メモリ | 31,700 KB |
| 最終ジャッジ日時 | 2024-07-04 16:10:42 |
| 合計ジャッジ時間 | 6,605 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 3 WA * 7 RE * 13 |
コンパイルメッセージ
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 System.Numerics;
static public class Program
{
//small
static public void Main()
{
var max = BigInteger.Pow(10, 6);
var S = readString(2).ValidateArray(x =>
{
var v = BigInteger.Parse(x);
return 1 <= v && v <= max;
});
readEOF();
var M = int.Parse(S[0]);
var D = int.Parse(S[1]);
var a = new int[5000];
long ans = 0;
for (int i = 1; i <= M; i++)
a[i.ToString().Select(x => x - '0').Sum()]++;
for (int i = 1; i <= D; i++)
ans += a[i.ToString().Select(x => x - '0').Sum()];
Console.WriteLine(ans);
}
static string[] readString(int n)
{
var s = Console.ReadLine().Split(' ');
if (s.Length != n)
throw new Exception(string.Format("invalid input, expected{0} actual{1}", n, s.Length));
return s;
}
static void readEOF()
{
if (Console.In.Peek() >= 0)
throw new Exception("invalid input too long input file");
}
}
static public class Ex
{
static public T[] ValidateArray<T>(this T[] input, Func<T, bool> f)
{
foreach (var x in input)
if (!f(x))
throw new Exception("invalid input");
return input;
}
}
紙ぺーぱー