結果
| 問題 | No.499 7進数変換 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-05 22:37:10 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 1,000 ms |
| コード長 | 754 bytes |
| コンパイル時間 | 1,948 ms |
| コンパイル使用メモリ | 104,064 KB |
| 実行使用メモリ | 17,792 KB |
| 最終ジャッジ日時 | 2024-11-06 22:30:21 |
| 合計ジャッジ時間 | 2,668 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
public class yukicoder
{
public static string Convert(long n, long x)
{
string result = "";
Stack<string> stack = new Stack<string>();
while (true)
{
if (n < x)
{
stack.Push(n.ToString());
break;
}
stack.Push((n % 7).ToString());
n = n / x;
}
int temp = stack.Count;
for (int i = 0; i < temp; i++)
{
result = result + stack.Pop();
}
return result;
}
public static void Main()
{
long n = long.Parse(Console.ReadLine());
Console.WriteLine(Convert(n, 7));
}
}