高精度模板
2016-10-30 21:50
218 查看
#include <bits/stdc++.h> using namespace std; struct _int{ int a1[510]; _int(){memset(a1, 0, sizeof a1);} _int operator * (const _int &t)const{ _int ans; for(int i = 1; i <= 500; i ++){ for(int j = 1; j <= 500; j ++){ if(i+j-1 <= 500) ans.a1[i+j-1] += a1[i]*t.a1[j]; } } for(int i = 1; i <= 500; i ++){ if(ans.a1[i]/10){ ans.a1[i+1] += ans.a1[i]/10; ans.a1[i] %= 10; } } return ans; } _int operator = (const int t1)const{ int len = 0, t = t1; _int ans; while(t){ ans.a1[++len] = t%10; t /= 10; } } void print(){ for(int i = 500; i >= 1; i --){ printf("%d", a1[i]); if(i%50 == 0) printf("\n"); } } }; int a1[510], a2[510]; int main(){ int n; scanf("%d", &n); cout << log(2)/log(10) << endl; cout << n*log(2) << endl; printf("%d\n", n*log(2)); _int a, b; a = 1, b = 2; for( ; n; n >>= 1, a = a * a) if(n&1) b = b*a; b.print(); return 0; }
相关文章推荐
- 【BZOJ2179】FFT快速傅立叶 高精度乘模板题
- [模板]高精度加、减、乘
- 高精度模板
- C++高精度大整数模板
- bign类C++高精度模板
- kuangbin高精度模板
- 高精度模板
- c++高精度模板
- 数据结构-超强超实用高精度模板之高精度bign类与高精度运算符重载
- 高精度之减法模板
- {模板}高精度压位
- 高精度模板
- LightOJ1214 - Large Division(高精度取模 + 模板)
- 大整数类BIGN的设计与实现 C++高精度模板
- [模板]高精度
- 高精度计算模板——棋盘覆盖问题
- 【高精度-加减乘除-模板】
- 我的高精度乘法模板
- POJ 3199 Uncle Jack大数的幂 利用高精度乘法模板
- 大整数类BIGN的设计与实现 C++高精度模板