Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9701

C#でAtCoder Beginners Selection(ABC087B - Coins)

$
0
0

準備

C#でAtCoderデビューのための準備
のあとで AtCoder Beginners Selection をやってみました。

問題文

ABC087B - Coins
https://atcoder.jp/contests/abs/tasks/abc087_b

提出結果

using System;

class Program
{
    static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());

        int choices = 0;
        for (int i = 0; i < a + 1; i++)
        {
            for (int j = 0; j < b + 1; j++)
            {
                for (int k = 0; k < c + 1; k++)
                {
                    if (((i * 500) + (j * 100) + (k * 50)) == x)
                    {
                        choices++;
                    }
                }

            }

        }
        Console.WriteLine($"{choices}");
    }
}

テスト実行

image.png
image.png
image.png


Viewing all articles
Browse latest Browse all 9701

Trending Articles