結果

問題 No.219 巨大数の概算
ユーザー koba-e964
提出日時 2015-05-29 23:45:19
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 28 ms / 1,500 ms
コード長 1,281 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 88,328 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-18 10:50:11
合計ジャッジ時間 3,866 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;


struct sci {
  double m;
  ll e;
  sci operator *(const sci & other) const {
    double r = m * other.m;
    ll re = e + other.e;
    if (r >= 10) {
      r /= 10;
      re++;
    }
    return (sci) {r, re};
  }
};


int main(void){
  int n;
  cin >> n;
  REP(i, 0, n) {
    ll a, b;
    cin >> a >> b;
    double m_a = a;
    ll e_a = 0;
    while (m_a >= 10) {
      m_a /= 10;
      e_a++;
    }
    sci s = (sci) {m_a, e_a};
    sci sum = (sci) {1, 0};
    sci cur = s;
    while (b > 0) {
      if (b % 2) {
	sum = sum * cur;
      }
      cur = cur * cur;
      b /= 2;
    }

    m_a = sum.m;
    cout << (int)m_a << " " << ((int)(m_a * 10) % 10) << " " << sum.e << endl;
  }
}
0