結果

問題 No.782 マイナス進数
ユーザー kuuso1kuuso1
提出日時 2019-01-11 22:07:27
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,630 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 109,844 KB
実行使用メモリ 29,188 KB
最終ジャッジ日時 2023-08-20 06:42:14
合計ジャッジ時間 7,754 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
20,816 KB
testcase_01 AC 61 ms
20,824 KB
testcase_02 AC 103 ms
24,884 KB
testcase_03 AC 106 ms
24,912 KB
testcase_04 AC 107 ms
25,004 KB
testcase_05 AC 103 ms
27,040 KB
testcase_06 AC 101 ms
26,900 KB
testcase_07 AC 112 ms
23,124 KB
testcase_08 AC 105 ms
26,948 KB
testcase_09 AC 104 ms
26,952 KB
testcase_10 AC 102 ms
22,876 KB
testcase_11 AC 113 ms
27,200 KB
testcase_12 AC 110 ms
27,052 KB
testcase_13 AC 127 ms
25,848 KB
testcase_14 AC 111 ms
27,116 KB
testcase_15 AC 111 ms
29,188 KB
testcase_16 AC 108 ms
27,148 KB
testcase_17 AC 119 ms
27,596 KB
testcase_18 AC 109 ms
27,104 KB
testcase_19 AC 116 ms
27,356 KB
testcase_20 AC 108 ms
24,980 KB
testcase_21 AC 116 ms
27,372 KB
testcase_22 AC 111 ms
25,184 KB
testcase_23 AC 107 ms
27,032 KB
testcase_24 AC 126 ms
27,912 KB
testcase_25 AC 109 ms
25,168 KB
testcase_26 AC 114 ms
25,288 KB
testcase_27 AC 111 ms
27,196 KB
testcase_28 AC 108 ms
25,052 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var sb = new StringBuilder();
		foreach(var n in Ns){
			
			int[] d = new int[60];
			long v = n;
			for(int i=0;i<60;i++){
				d[i] = (int)(v % B);
				v /= B;
			}
			for(int i=0;i<59;i++){
				if(i % 2 == 0){
					if(d[i] < B) continue;
					d[i + 1] += d[i] / B;
					d[i] %= B;
				} else {
					d[i + 1] += d[i] / B;
					d[i] %= B;
					if(d[i] > 0){
						d[i + 1] += 1;
						d[i] = B - d[i];
					}
				}
			}
			var l = new List<int>();
			for(int i=0;i<60;i++) l.Add(d[i]);
			while(l[l.Count - 1] == 0) l.RemoveAt(l.Count - 1);
			l.Reverse();
			sb.AppendLine(String.Join("",l));
		}
		
		Console.Write(sb.ToString());
	}
	int T, B;
	long[] Ns;
	public Sol(){
		var d = ria();
		T = d[0]; B = -d[1];
		Ns = new long[T];
		for(int i=0;i<T;i++) Ns[i] = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0