2
1

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 5 years have passed since last update.

AtCoder 過去問精選 10 問 を Ada で解いてみる

Last updated at Posted at 2019-01-02

#はじめに
タイトルの通りですが、受験生なもので、勉強の合間にやりたいと思います。
そのため随時更新していく形になりますがなにとぞよろしくお願いします。

「AtCoder に登録したら次にやること ~ これだけ解けば十分闘える!過去問精選 10 問 ~」

こちらの記事の問題をAda言語で10問解いていこうと思います。

#環境

  • OS : Windows10
  • IDE : GNAT community 2018

第1問 : ABC 086 A - Product (100 点)

with Ada.Text_IO;
with Ada.Integer_Text_IO;

procedure main is

   a, b : Integer;

begin

   Ada.Integer_Text_IO.Get(a, 0);
   Ada.Integer_Text_IO.Get(b, 0);

   if ( (a * b) rem 2 ) = 0 then
      Ada.Text_IO.Put_Line("Even");
   else
      Ada.Text_IO.Put_Line("Odd");
   end if;

end main;

第 2 問: ABC 081 A - Placing Marbles (100 点)

with Ada.Text_IO;
with Ada.Integer_Text_IO;

procedure main is
   
   s : String (1 .. 3);
   last : Natural;
   counter : Integer := 0;
   
begin
   
   Ada.Text_IO.Get_Line(s, last);
   
   if(s(1) = '1')then
      counter := counter + 1;
   end if;
   
   if(s(2) = '1')then
      counter := counter + 1;
   end if;
   
   if(s(3) = '1')then
      counter := counter + 1;
   end if;
   
   Ada.Integer_Text_IO.Put(counter, 0);
   
end main;

第 3 問: ABC 081 B - Shift Only (200 点)

第 4 問: ABC 087 B - Coins (200 点)

第 5 問: ABC 083 B - Some Sums (200 点)

第 6 問: ABC 088 B - Card Game for Two (200 点)

第 7 問: ABC 085 B - Kagami Mochi (200 点)

第 8 問: ABC 085 C - Otoshidama (300 点)

第 9 問: ABC 049 C - Daydream (300 点)

第 10 問: ABC 086 C - Traveling (300 点)

#おわりに
センター試験やってる場合じゃねぇ!

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?