結果

問題 No.219 巨大数の概算
ユーザー imulanimulan
提出日時 2016-01-25 03:19:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 1,500 ms
コード長 1,269 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 73,672 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 15:07:25
合計ジャッジ時間 5,036 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
4,380 KB
testcase_01 AC 31 ms
4,380 KB
testcase_02 AC 30 ms
4,376 KB
testcase_03 AC 31 ms
4,376 KB
testcase_04 AC 27 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 31 ms
4,380 KB
testcase_11 AC 30 ms
4,380 KB
testcase_12 AC 30 ms
4,380 KB
testcase_13 AC 31 ms
4,384 KB
testcase_14 AC 31 ms
4,376 KB
testcase_15 AC 31 ms
4,380 KB
testcase_16 AC 30 ms
4,380 KB
testcase_17 AC 30 ms
4,380 KB
testcase_18 AC 31 ms
4,376 KB
testcase_19 AC 30 ms
4,380 KB
testcase_20 AC 31 ms
4,380 KB
testcase_21 AC 31 ms
4,380 KB
testcase_22 AC 31 ms
4,380 KB
testcase_23 AC 31 ms
4,380 KB
testcase_24 AC 30 ms
4,380 KB
testcase_25 AC 31 ms
4,376 KB
testcase_26 AC 31 ms
4,380 KB
testcase_27 AC 30 ms
4,380 KB
testcase_28 AC 30 ms
4,376 KB
testcase_29 AC 30 ms
4,376 KB
testcase_30 AC 30 ms
4,376 KB
testcase_31 AC 31 ms
4,380 KB
testcase_32 AC 30 ms
4,376 KB
testcase_33 AC 31 ms
4,380 KB
testcase_34 AC 31 ms
4,380 KB
testcase_35 AC 31 ms
4,380 KB
testcase_36 AC 30 ms
4,384 KB
testcase_37 AC 30 ms
4,376 KB
testcase_38 AC 31 ms
4,376 KB
testcase_39 AC 31 ms
4,376 KB
testcase_40 AC 31 ms
4,384 KB
testcase_41 AC 30 ms
4,376 KB
testcase_42 AC 31 ms
4,380 KB
testcase_43 AC 30 ms
4,380 KB
testcase_44 AC 31 ms
4,376 KB
testcase_45 AC 30 ms
4,376 KB
testcase_46 AC 30 ms
4,380 KB
testcase_47 AC 30 ms
4,376 KB
testcase_48 AC 30 ms
4,376 KB
testcase_49 AC 30 ms
4,384 KB
testcase_50 AC 30 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)

int main(int argc, char const *argv[]) {
  int n;
  cin >>n;
  for(int t=0; t<n; ++t){
    long a,b;
    cin >>a >>b;

    double pw[33]={0};
    ll n10[33]={0};

    pw[0]=a;
    while(pw[0]>=10){
      pw[0]/=10;
      ++n10[0];
    }


    for(int i=1; i<=32; ++i){
      pw[i]=pw[i-1]*pw[i-1];
      n10[i]=2*n10[i-1];
      while(pw[i]>=10){
        pw[i]/=10;
        ++n10[i];
      }
    }

    /*
    for(int i=0; i<=32; ++i){
      printf("%.3lf %lld\n",pw[i], n10[i]);
    }
    */
    double p=1.0;
    ll ct=0;
    for(int i=0; i<32; ++i){
      if((b>>i)&1){
        p*=pw[i];
        ct+=n10[i];
      }
    }

    while(p>=10){
      p/=10;
      ++ct;
    }

    p*=10;
    int pp=(int)p;

    printf("%d %d %lld\n",pp/10,pp%10,ct);
  }
  return 0;
}
0