当前位置: 首页 > news >正文

网站微信建设方案百度推广个人能开户吗

网站微信建设方案,百度推广个人能开户吗,淮北人论坛招聘信息,中山市高精度算法 分为四则运算加减乘除 适用条件 都高精度了,肯定时long long都会爆的情况——一般与阶乘有关 注意事项 用数组模拟位运算,最后在一起考虑进位 注意res[i1]res[i]/10; 是""不是 两数相加,相乘数组的新长度会变&…

高精度算法

  • 分为四则运算加减乘除

适用条件

  • 都高精度了,肯定时long long都会爆的情况——一般与阶乘有关

注意事项

  • 用数组模拟位运算,最后在一起考虑进位
    • 注意res[i+1]+=res[i]/10; 是"+="不是=
  • 两数相加,相乘数组的新长度会变,要正确计算!
    • 加法:len=max(lena,lenb)+1
    • 乘法:len=lena+lenb+1
  • 位运算的公式
    • 加法:a[i] += b[i];
    • 乘法:res[i+j-1]+=a[i]*b[j];模拟乘法运算,一个数字乘以行的情况
  • 对于阶乘:
    • 最好是定义一个类bigInt,便于组织代码
    • for(int i=2;i<=n;i++){ x*i }利用循环模拟,不建议递归

加法模板

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
string stra, strb;
int a[5009];
int b[5009];
void solve() {cin >> stra >> strb;int lena = stra.size(), lenb = strb.size();for (int i = lena-1; i >= 0; i--) {a[lena - i] = stra[i]-'0';}/*for (int i = lena; i >= 1; i--) {cout << a[i];}cout << endl;*/for (int i = lenb - 1; i >= 0; i--) {b[lenb - i] = strb[i]-'0';}/*for (int i = lenb; i >= 1; i--) {cout << b[i];}cout << endl;*/int len = max(lena, lenb) + 2;for (int i = 1; i <= len; i++) {a[i] += b[i];}//for (int i = len; i >= 1; i--) {//    cout << a[i] << " ";//}//cout << endl;for (int i = 1; i <= len; i++) {a[i + 1] += a[i] / 10;a[i] %= 10;}/*for (int i = len; i >= 1; i--) {cout << a[i] << " ";}*/for (; a[len]==0&&len>0;len--);if (len <=1) {cout << 0;return;}for (int i = len; i >= 1; i--) {cout << a[i];}
}

乘法模板

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
string stra, strb;
int a[5009];
int b[5009];
int res[5009];
void solve() {cin >> stra >> strb;int lena = stra.size(), lenb = strb.size();for (int i = lena-1; i >= 0; i--) {a[lena - i] = stra[i]-'0';}for (int i = lenb - 1; i >= 0; i--) {b[lenb - i] = strb[i]-'0';}int len = lena + lenb + 2;for (int i = 1; i <= lena; i++) {for (int j = 1; j <= lenb; j++) {res[i + j - 1] += a[i] * b[j];}}/*for (int i = 1; i <= 10; i++) {cout << res[i] << " ";}cout << endl;*/for (int i = 1; i <= len; i++) {res[i + 1] += res[i] / 10;res[i] %= 10;}/*for (int i = 1; i <= 10; i++) {cout << res[i] << " ";}*//*for (int i = len; i >= 1; i--) {cout << a[i] << " ";}*/for (; res[len]==0&&len>0;len--);if (len <1) {cout << 0;return;}for (int i = len; i >= 1; i--) {cout << res[i];}
}

阶乘模板

using namespace std;
using ll = long long;
int t,n,a,ct;
class bigInt {
public://构造一个类,避免重复开辟新空间int a[5009];int len;bigInt() {memset(a, 0, sizeof(a));a[1] = 1;len = 1;}void operator*(int b) {for (int i = 1; i <= len; i++) {a[i] *= b;}len += b/10+1;//扩容不是固定的+2!!!for (int i = 1; i <= len; i++) {a[i + 1] += a[i] / 10;a[i] %= 10;}for (; a[len]==0; len--);}void print() {for (int i = len; i >= 1; i--) {cout << a[i];}}
};
bigInt number;
void solve() {cin >> t;while (t--) {cin >> n >> a;if (n == 0) {//特判0!=1(也可以不特判)cout << (a == 1 ? 1 : 0); continue;}for (int i = 2; i <= n; i++) {number* i;//原地对number不断发生阶乘运算//你也可以定义=运算符,但是我懒}number.print();cout << endl;}
}

以下均为例题

阶乘数码

题目描述

n ! n! n! 中某个数码出现的次数。

输入格式

第一行为 t ( t ≤ 10 ) t(t \leq 10) t(t10),表示数据组数。接下来 t t t 行,每行一个正整数 n ( n ≤ 1000 ) n(n \leq 1000) n(n1000) 和数码 a a a

输出格式

对于每组数据,输出一个整数,表示 n ! n! n! a a a 出现的次数。

样例 #1

样例输入 #1

2
5 2
7 0

样例输出 #1

1
2
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int t,n,a,ct;
class bigInt {
public:int a[5009];int len;bigInt() {memset(a, 0, sizeof(a));a[1] = 1;len = 1;}void operator*(int b) {for (int i = 1; i <= len; i++) {a[i] *= b;}len += b/10+1;//扩容不是固定的+2!!!for (int i = 1; i <= len; i++) {a[i + 1] += a[i] / 10;a[i] %= 10;}for (; a[len]==0; len--);}void print() {for (int i = len; i >= 1; i--) {cout << a[i];}}
};
bigInt number;
void solve() {cin >> t;while (t--) {cin >> n >> a;if (n == 0) {cout << (a == 1 ? 1 : 0); continue;}memset(number.a, 0, sizeof(number.a));number.a[1] = 1;number.len = 1;ct = 0;//初始化for (int i = 2; i <= n; i++) {number* i;//不断发生变换}/*number.print();cout << endl;*/for (int i = 1; i <= number.len; i++) {if (number.a[i] == a) {ct++;}}cout << ct<<endl;}
}
signed main() {std::ios::sync_with_stdio(false);std::cin.tie(0); std::cout.tie(0);solve();return 0;
}
http://www.hkea.cn/news/385749/

相关文章:

  • 怎么做资源类网站百度搜索热度排名
  • 大片网站建设seo关键词排名优化评价
  • 网络营销推广课程培训苏州seo门户网
  • 做盗版影视网站如何给公司网站做推广
  • 做网站付费流程郑州seo技术
  • 云南网站开发有哪些实用的网络推广方法
  • 央视新闻最新消息今天什么叫seo
  • 网站建设的意义徐州百度推广
  • 建设网站建设的目标百度云盘资源
  • 个体工商户是否能够做网站在线生成个人网站源码
  • 临沂高端网站建设厦门网站推广费用
  • 网站模版友链交易交易平台
  • 武汉做网站找谁百度导航是哪个国家的
  • wordpress互动游戏黄石seo诊断
  • 网页设计作品下载志鸿优化设计
  • 宾馆网站制作seminar是什么意思
  • 网站建设的进度表爱站查询工具
  • 深圳聘请做网站人员长春刚刚最新消息今天
  • 汽配人网做网站沈阳网站seo公司
  • 网站 短链接怎么做网站建设网站定制
  • 网站开发凭证做什么科目百度推广关键词多少合适
  • 网站正在建设 h5模板新闻热点
  • 龙岗公司网站建设怎么上百度搜索
  • 七米网站建设网站自动推广软件免费
  • 余姚公司做网站跨境电商怎么做
  • 顺义哪有做网站厂家百度快照在哪里找
  • 深圳南山网站建设重庆seo黄智
  • 教育微网站建设我要学电脑哪里有短期培训班
  • 民宿预订网站制作推广方案怎么做
  • 做网站都要掌握什么网页模版