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

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

パナソニックコンテストで書いたコード

using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Atcoder20190616
{
    class ProgramA
    {
        static void Main(string args)
        {
            //入力
            int a = {11121215221512114151522115225414151};
            int k = int.Parse(Console.ReadLine());

            //数列のk番目の要素を出す
            Console.WriteLine(a[k -1]);
        }
    }

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

            //hかwが1のときは移動できない
            if(h == 1 || w == 1)
            {
                Console.WriteLine("1");
                return;
            }

            //両方奇数のときは足し合わせる
            if(h % 2 == 1 && w % 2 == 1)
                Console.WriteLine(h*w /2 + 1);
            else
                Console.WriteLine(h*w /2);
    
        }
    }

    class ProgramC
    {
        static void Main(string args)
        {
            
            //入力
            string input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1]);
            long c = long.Parse(input[2]);
            
            //二乗した差を考える。変形すると(c-a-b)^2 > 4abを満たすかどうかになる
            long left = c - a - b;
            long right = 4 * ab;

            //c-a-bが負だと満たさない
            if(left <= 0)
            {
                Console.WriteLine("No");
                return;
            }
            
            //あとは条件を満たすか確認
            if(left * left > right)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        } 
    }  

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

            //深さ優先検索
            dfs(""'a'n);//1つ目は文字列を保存する、2つ目はfor文で繰り返すべき文字、3つ目は全文字数
            
        }

        static void dfs(string schar mxint n)
        {
            //n文字まで行ったら末端なのでそれは出力する
            if(s.Length == n)
                Console.WriteLine(s);
            else
            {
                //もし最後の文字なら次の数ではその並びもあり得るので追加する
                for(char c ='a'c <=mx;c++)
                    dfs(s + c, (c == mx)  ? (char)(mx + 1) : mxn);
            }
        }
 
    }
}