0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C#でAtCoder Beginners Selection(ABC083B - Some Sums)

Last updated at Posted at 2021-01-21

####準備
[C#でAtCoderデビューのための準備]
(https://qiita.com/azumabashi/items/7aa9e4b77c10970cc30a)
のあとで AtCoder Beginners Selection をやってみました。

####問題文
ABC083B - Some Sums
[https://atcoder.jp/contests/abs/tasks/abc083_b]
(https://atcoder.jp/contests/abs/tasks/abc083_b)

####提出結果

using System;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int a = int.Parse(input[1]);
		int b = int.Parse(input[2]);

		int souwa = 0;
		for (int i = 1; i <= n; i++)
        {
			// 強引だけれど結果オーライ
			int i10000 = i / 10000;
			int i1000 = (i % 10000) / 1000;
			int i100 = (i % 1000) / 100;
			int i10 = (i % 100) / 10;
			int i1 = i % 10;
			int wa = i10000 + i1000 + i100 + i10 + i1;
			if ((wa >= a) && (wa <= b))
			{
				souwa += i;
            }
		}
		Console.WriteLine($"{souwa}");
	}
}

####テスト実行
image.png
image.png
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?