結果

問題 No.219 巨大数の概算
ユーザー satanic
提出日時 2016-05-14 04:34:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,385 bytes
コンパイル時間 1,350 ms
コンパイル使用メモリ 165,988 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-06 02:07:57
合計ジャッジ時間 10,112 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, a) type a;std::cin>>a;
// VAR(int, x);
#define OUT(d) std::cout<<(d);
#define SP std::cout<<" ";
#define ENDL std::cout<<"\n";
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using ll = long long;
ll cnt = 0;
ll RepeatSquaring(ll N, ll P){
    //OUT(N)SP OUT(P)ENDL;
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2);
        ll tt = t*t;
        cnt *= 2;
        while(tt>=2100000000){
            tt/=10;
            ++cnt;
        }
        return tt;
    }
    ll res = N * RepeatSquaring(N, P-1);
    while(res>=2100000000){
        res/=10;
        ++cnt;
    }
    return res;
}

signed main(){
    INIT;
    VAR(int, n);
    REP(i, n){
        cnt = 0;
        VAR(int, a);VAR(int, b);
        ll ans = RepeatSquaring(a, b);
        while(ans>=100){
            ans/=10;
            ++cnt;
        }
        OUT(ans/10)SP OUT(ans%10)SP OUT(cnt+1)ENDL;
    }
    return 0;
}
0