結果

問題 No.782 マイナス進数
ユーザー kotatsugame
提出日時 2019-01-27 15:45:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 237 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 65,232 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 17:42:52
合計ジャッジ時間 2,434 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int t,b;
void f(int n)
{
	if(!n)return;
	f(n>0?-(n/-b):(-n-b-1)/-b);
	cout<<(n>0?n%-b:(-b-(-n%-b?-n%-b:-b)));
}
main()
{
	cin>>t>>b;
	for(;t--;)
	{
		int n;cin>>n;f(n);cout<<(n?"":"0")<<endl;
	}
}
0