結果

問題 No.782 マイナス進数
ユーザー yuliicppyyuliicppy
提出日時 2019-04-24 16:20:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,088 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 83,540 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 15:13:54
合計ジャッジ時間 3,289 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 26 ms
6,944 KB
testcase_03 AC 25 ms
6,944 KB
testcase_04 AC 28 ms
6,940 KB
testcase_05 AC 25 ms
6,940 KB
testcase_06 AC 24 ms
6,940 KB
testcase_07 AC 30 ms
6,940 KB
testcase_08 AC 26 ms
6,940 KB
testcase_09 AC 26 ms
6,944 KB
testcase_10 AC 25 ms
6,940 KB
testcase_11 AC 32 ms
6,940 KB
testcase_12 AC 33 ms
6,940 KB
testcase_13 AC 45 ms
6,944 KB
testcase_14 AC 35 ms
6,944 KB
testcase_15 AC 36 ms
6,940 KB
testcase_16 AC 35 ms
6,944 KB
testcase_17 AC 38 ms
6,940 KB
testcase_18 AC 35 ms
6,940 KB
testcase_19 AC 36 ms
6,944 KB
testcase_20 AC 34 ms
6,940 KB
testcase_21 AC 38 ms
6,940 KB
testcase_22 AC 35 ms
6,944 KB
testcase_23 AC 36 ms
6,940 KB
testcase_24 AC 46 ms
6,940 KB
testcase_25 AC 35 ms
6,944 KB
testcase_26 AC 35 ms
6,944 KB
testcase_27 AC 35 ms
6,940 KB
testcase_28 AC 36 ms
6,940 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL T,B; cin >>T>>B;
    vector<LL> N(T);
    REP(i,T) cin >> N[i];

    REP(i,T)
    {
        vector<LL> ans;
        LL nowMod = 0;
        LL nowSum = 0;
        LL divisor = B;
        while(nowSum != N[i])
        {
            LL obj = (N[i]-nowSum) % abs(divisor);
            dump(divisor)
            REP(j,abs(B))
            {
                LL tmp = ((divisor/B) * j) % divisor;
                if(tmp < 0) tmp += divisor;

                dump(tmp)

                if(tmp == obj)
                {
                    ans.pb(j);
                    nowSum += ((divisor/B) * j);
                    break;
                }
            }
            dump(nowSum)
            divisor *= B;
        }
        reverse(ans.begin(), ans.end());
        for(auto p : ans) cout << p;
        cout << endl;
    }

}
0