東大卒のお金やりくり奮闘記~株、家計、趣味、経済~

東大卒でメーカー勤務の私がセミリタイアするために投資などを頑張っていこうという趣旨で始めたブログです。既婚男性です。株、家計、趣味、経済の話をメインにゆるゆる話します。

ABC152で書いたコード

using System;
using System.Linq;
using System.Collections.Generic;

namespace Atcoder20190616
{
    class ProgramA
    {
        static void Main(string args)
        {
            //入力
            string input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);

            //m=nならYes,それ以外ならNo
            if(m == n)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }

    class ProgramB
    {
        static void Main(string args)
        {
            //入力
            string input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);


            //aとb小さい方の数で出力
            if(a >= b)
            {
                for(int i = 0;i < a;i++)
                    Console.Write(b);
                
            }
            else
            {
                for(int i = 0;i < b;i++)
                    Console.Write(a);
            }
    
        }
    }

    class ProgramC
    {
        static void Main(string args)
        {
            
            //入力
            int n = int.Parse(Console.ReadLine());
            string input = Console.ReadLine().Split(' ');
            int a = new int[n];

            for(int i = 0;i < n;i++)
                a[i] = int.Parse(input[i]);
            
            int count = 0;
            int min = 0;
            
            //最初は満たすので加算、そのあとは最小値より小さい場合が満たすのでカウントして、その値を更新
            for(int i = 0;i < n;i++)
            {
                if(i == 0)
                {
                    count++;
                    min = a[0];
                    continue;
                }

                if(min > a[i])
                {
                    count++;
                    min = a[i];
                }
            }

            Console.WriteLine(count);
          
        } 
    }   

    class ProgramD
    {
        static void Main(string args)
        {
            
            //入力
            int n = int.Parse(Console.ReadLine());
            int n2 = n;
            int keta = 0;

            int count = 1;
            
            for(int i = 2;i <= n;i++)
            {
                //下一桁0は除外
                if(i % 10 == 0)
                    continue;

                //それぞれ桁数によって場合分け
                if(i < 10) //1桁のとき
                {
                    count++;
                }
                else if(i <= 11 && i <= 99) //2桁のとき
                {
                    //けたを分割
                    int a1 = i /10;
                    int a2 = i - a1*10;

                    //条件分け
                    if(a1 == a2)
                        count += 3;
                    else if(a1 > a2)
                        count += 2;
                }
                else if(101 <= i && i <= 999) //3桁のとき
                {
                    //けたを分割
                    int b1 = i / 100;
                    int b2 = (i - b1*100)/10;
                    int b3 = i - b2*10 - b1*100;

                    //条件分け
                    if(b1 == b3)
                        count += 5 + b2*2;
                    else if(b1 > b3)
                        count += 22;
                    else if(b1 < b3)
                        count += 2;
                    
                }
                else if(1001 <= i && i <= 9999) //4桁のとき
                {
                    //けたを分割
                    int c1 = i / 1000;
                    int c2 = (i - c1*1000)/100;
                    int c3 = (i - c2*100 - c1*1000)/10;
                    int c4 = i - c3*10 - c2*100 - c1*1000;

                    //条件分け
                    if(c1 == c4)
                        count += 25 + c2*20 + c3*2;
                    else if(c1 > c4)
                        count += 222;
                    else if(c1 < c4)
                        count += 22;
                    
                }
                else if(10001 <= i && i <= 99999) //5桁のとき
                {
                    //けたを分割
                    int d1 = i / 10000;
                    int d2 = (i - d1*10000)/1000;
                    int d3 = (i - d2*1000 - d1*10000)/100;
                    int d4 = (i - d3*100 - d2*1000 - d1*10000)/10;
                    int d5 = i - d4*10 - d3*100 - d2*1000 - d1*10000;
                    
                    //条件分け
                    if(d1 == d5)
                        count += 225 + d2*200 + d3*20 + d4*2;
                    else if(d1 > d5)
                        count += 2222;
                    else if(d1 < d5)
                        count += 222;
                    
                }
                else if(100001 <= i) //6桁のとき
                {
                    //けたを分割
                    int e1 = i / 100000;
                    int e2 = (i - e1*100000)/10000;
                    int e3 = (i - e2*10000 - e1*100000)/1000;
                    int e4 = (i - e3*1000 - e2*10000 - e1*100000)/100;
                    int e5 = (i - e4*100 - e3*1000 - e2*10000 - e1*100000)/10;
                    int e6 = i - e5*10 - e4*100 - e3*1000 - e2*10000 - e1*100000;

                    //条件分け
                    if(e1 == e6)
                        count += 2225 + e2*2000 + e3*200 + e4*20 + e5*2;
                    else if(e1 > e6)
                        count += 22222;
                    else if(e1 < e6)
                        count += 2222;
                    
                }
                
            }

            //答え出力
            Console.WriteLine(count);
          
        } 
    } 

           
}