結果
| 問題 |
No.219 巨大数の概算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-13 04:44:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,584 bytes |
| コンパイル時間 | 819 ms |
| コンパイル使用メモリ | 114,616 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 15:58:30 |
| 合計ジャッジ時間 | 4,237 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 50 WA * 1 |
ソースコード
// #ifdef DEBUG
// #define _GLIBCXX_DEBUG
// #endif
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
// these require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>
using namespace std;
#define int long long
#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif
template<typename A,typename B>
ostream &operator<<(ostream&os,const pair<A,B>& p){
os << "(" << p.first << "," << p.second << ")";
return os;
}
typedef complex<double> point;
// template<typename T,std::size_t N>
// struct _v_traits {using type = std::vector<typename _v_traits<T,N-1>::type>;};
// template<typename T>
// struct _v_traits<T,1> {using type = std::vector<T>;};
// template<typename T,std::size_t N=1>
// using vec = typename _v_traits<T,N>::type;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
template<typename T,typename F>
T apply_doubling(const T& x,
const long long& n,
const T& id_elem,
const F& binary_op){
if(n == 0) return id_elem;
T ret = apply_doubling(binary_op(x,x),n/2,id_elem,binary_op);
if(n % 2 == 1) ret = binary_op(ret,x);
return ret;
}
struct P {
double k;
int p;
};
double EPS = 1e-7;
P multi(P l,P r){
double k = l.k * r.k;
int p = l.p + r.p;
while(k >= 10 - EPS){
k /= 10;
p++;
}
return P{k,p};
}
ostream& operator<<(ostream& os,const P& p){
int x = (int)floor(p.k);
int y = (int)floor(p.k*10) % 10;
return os << x << " " << y << " " << p.p;
}
P henkan(int k){
return multi(P{1.0*k,0},P{1,0});
}
P solve(int a,int b){
return apply_doubling(henkan(a),b,P{1,0},multi);
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N; cin >> N;
for(int i=0;i<N;i++){
int A,B;
cin >> A >> B;
cout << solve(A,B) << endl;
}
return 0;
}