結果
| 問題 | No.782 マイナス進数 | 
| コンテスト | |
| ユーザー |  ats5515 | 
| 提出日時 | 2019-01-11 22:13:55 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 2,000 ms | 
| コード長 | 828 bytes | 
| コンパイル時間 | 674 ms | 
| コンパイル使用メモリ | 84,208 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-30 08:11:30 | 
| 合計ジャッジ時間 | 2,481 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 36 | 
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	int A;
	vector<string> res(N);
	for (int i = 0; i < N; i++) {
		cin >> A;
		while (A != 0) {
			if (A < 0) {
				int t = abs(A) % (-K);
				if (t != 0)t = (-K) - t;
				res[i].push_back(t + '0');
				A -= t;
				A /= -K; A =  -A;
			}
			else {
				int t = abs(A) % (-K);
				res[i].push_back(t+ '0');
				A -= t;
				A /= -K; A = -A;
			}
		}
		if (res[i].size() == 0)res[i].push_back('0');
		reverse(res[i].begin(), res[i].end());
	}
	for (int i = 0; i < N; i++) {
		cout << res[i] << endl;
	}
}
            
            
            
        