結果

問題 No.428 小数から逃げる夢
ユーザー jousen
提出日時 2016-10-02 23:17:49
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,964 bytes
コンパイル時間 2,968 ms
コンパイル使用メモリ 115,032 KB
実行使用メモリ 28,008 KB
最終ジャッジ日時 2024-11-21 13:34:38
合計ジャッジ時間 5,124 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 90
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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


namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			 
            var num = int.Parse(Console.ReadLine());

            string D = "0.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991";

            var arr = new string[19];

            for(int i =0; i<19; i++)
            {
                arr[i] = D.Substring(2+(i*10), 10);
            }
            


            var change = new long[19];
            for(int i =0; i<19; i++)
            {
                string t = arr[i];
                long tmp = 0;
                if(t[0]=='0')
                {
                    tmp = long.Parse(t.Substring(1));
                }
                else{
                    tmp = long.Parse(t);
                }

                change[i] = tmp * num;
            }

            string ans = "";

            var over = new long[19];
            for(int i = change.Length-1; i>=0; i--)
            {
                long tmp = change[i];

                if(i%2 == 1 )
                {
                    int len = tmp.ToString().Length;
                    if (tmp.ToString().Length > 10)
                    {
                        
                        over[i] = long.Parse(tmp.ToString().Substring(0, len - 10));
                        change[i] = long.Parse(tmp.ToString().Substring(len - 10));
                    }
                    else if(len<10)
                    {
                        over[i] = -1;
                    }

                }
                else
                {
                    int len = tmp.ToString().Length;
                    if (tmp.ToString().Length>10)
                    {
                        
                        over[i] = long.Parse(tmp.ToString().Substring(0,len-10));
                        change[i] = long.Parse(tmp.ToString().Substring(len - 10));
                    }

                }

            }

            for(int i=0; i<19; i++)
            {
                if (i == 0)
                {
                    if (over[0] > 0) ans += over[0].ToString() + "." + change[i].ToString();
                    else ans += "0." + change[i].ToString();

                    if (over[i + 1] < 0) ans += "0";
                }
                else if (i < 18 && (over[i + 1] > 0))
                {
                    long tmp = change[i] + over[i + 1];
                    ans += tmp.ToString();
                }
                else if (i < 18 && over[i + 1] < 0)
                {
                    ans += change[i].ToString() + "0";
                }
                else
                {
                    ans += change[i].ToString();
                }
            }

            Console.WriteLine(ans);
		}				 
	}
}
0