请求出1!+2!+3!+4!+…+n!,请注意,n<=50。 n!=nx(n-1)x(n-2)x…x1,如:5!=5x4x3x2x1=120。 c++ using namespace std;要有 不要注释 使用高精度算法
```cpp #include <iostream> #include <vector> #include <algorithm> using namespace std; // 高精度乘法 vector<int> multiply(vector<int> num, int x) { int carry = 0; for (int i = 0; i < num.size(); i++) { int prod = num[i] * x + carry; num[i] = prod % 10; carry = prod / 10; } while (carry) { num.push_back(carry % 10); carry /= 10; } return num; } // 高精度加法 vector<int> add(vector<int> num1, vector<int> num2) { vector<int> result; int carry = 0; int i = 0, j = 0; while (i < num1.size() || j < num2.size() || carry) { int sum = carry; if (i < num1.size()) sum += num1[i++]; if (j < num2.size()) sum += num2[j++]; result.push_back(sum % 10); carry = sum / 10; } return result; } // 输出高精度数 void print(vector<int> num) { for (int i = num.size() - 1; i >= 0; i--) { cout << num[i]; } cout << endl; } int main() { int n; cin >> n; vector<int> factorial(1, 1); vector<int> sum(1, 0); for (int i = 1; i <= n; i++) { factorial = multiply(factorial, i); sum = add(sum, factorial); } print(sum); return 0; } ``` [2025-09-26 19:33:39 | AI问答 | 439点数解答]
- [字节豆包] 请求出1!+2!+3!+4!+…+n!,请注意,n<=50。 n!=nx(n-1)x(n-2)x…x1,如:5!=5x4x3x2x1=120。 c++ using namespace std;要有 不要注释(99点数解答 | 2025-09-26 19:32:04)35
- [字节豆包] 请求出1!+2!+3!+4!+…+n!,请注意,n<=50。 n!=nx(n-1)x(n-2)x…x1,如:5!=5x4x3x2x1=120。 c++ using namespace std;要有 不要注释 使用高精度算法(439点数解答 | 2025-09-26 19:33:39)27
- [DeepSeek] using communication_protocols; using FTS_F02391A; using NLog; using ScottPlot.Plottable; using Sunny.UI; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace 窗体界面设计 { public partial class FormHome : UIPage { private readonly DataLogger Log1;//波形图数据记录器 bool bViewSlide = false(562点数解答 | 2025-07-09 16:57:56)134
- [字节豆包] #define _crt_secure_no_warnings #include <iostream> #include <cstdlib> #include <cmath> #include <vector> #include <cstdio> using namespace std; // 你的代码... const int nx = 784, nb = 500, ny = 10;//输入层x,隐藏层b,输出层y节点数 const double eta = 0.1;//学习率 struct node { double val{}; double bias{}; vector<double> weight; } x[nx], b[nb], y[ny];//输入层x,隐藏层b,输出层y double g[ny], e[nb];//用于反向传播 double trainx[nx], trainy[ny];//训练数据 double sigmoid(double x) { return 1.0 / (1.0 + exp(-x)); } double(34点数解答 | 2024-09-06 08:43:52)297
- [GPT] #define _crt_secure_no_warnings #include <iostream> #include <cstdlib> #include <cmath> #include <vector> #include <cstdio> using namespace std; // 你的代码... const int nx = 784, nb = 500, ny = 10;//输入层x,隐藏层b,输出层y节点数 const double eta = 0.1;//学习率 struct node { double val{}; double bias{}; vector<double> weight; } x[nx], b[nb], y[ny];//输入层x,隐藏层b,输出层y double g[ny], e[nb];//用于反向传播 double trainx[nx], trainy[ny];//训练数据 double sigmoid(double x) { return 1.0 / (1.0 + exp(-x)); } double(1309点数解答 | 2024-09-06 08:46:09)313
- [字节豆包] 题目描述 给定m行n列的图像各像素点的灰度值,要求用如下方法对其进行模糊化处理: 1.四周最外侧的像素点灰度值不变; 2.中间各像素点新灰度值为该像素点及其上下左右相邻四个像素点原灰度值的平均值(四舍五入)。 输入格式 第一行包含两个整数n和m,表示图像包含像素点的行数和列数。1<=n<=100,1<=m<=100。 接下来n行,每行m个整数,表示图像的每个像素点灰度。相邻两个整数之间用单个空格隔开,每个元素均在0~255之间。 输出格式 m行,每行n个整数,为模糊处理后的图像。相邻两个整数之间用单个空格隔开。 输入样例1 4 5 100 0 100 0 50 50 100 200 0 0 50 50 100 100 200 100 100 50 50 100 输出样例1 100 0 100 0 50 50 80 100 60 0 50 80 100 90 200 100 100 50 50 100 用c++语言 (670点数解答 | 2025-11-10 18:55:33)39
- [字节豆包] 题目描述 给定m行n列的图像各像素点的灰度值,要求用如下方法对其进行模糊化处理: 1.四周最外侧的像素点灰度值不变; 2.中间各像素点新灰度值为该像素点及其上下左右相邻四个像素点原灰度值的平均值(四舍五入)。 输入格式 第一行包含两个整数n和m,表示图像包含像素点的行数和列数。1<=n<=100,1<=m<=100。 接下来n行,每行m个整数,表示图像的每个像素点灰度。相邻两个整数之间用单个空格隔开,每个元素均在0~255之间。 输出格式 m行,每行n个整数,为模糊处理后的图像。相邻两个整数之间用单个空格隔开。 输入样例 4 5 100 0 100 0 50 50 100 200 0 0 50 50 100 100 200 100 100 50 50 100 输出样例 100 0 100 0 50 50 80 100 60 0 50 80 100 90 200 100 100 50 50 100 说明/提示 用c++(655点数解答 | 2025-12-01 14:24:01)15
- [字节豆包] 向一个空栈压入正整数,每当压入一-个整数时,执行以下规则(设:栈顶至栈底整数依次编号为n1,n2,...,nx…,其中n1,为最新压入的整数) 1.如果n1 = n2,则n1、 n2全部出栈,压入新数据m = 2n1 2.如果n1 = n2 + ...+ ny (y ∈[3,x]),则 n1,n2,...,ny全部出栈,压入新数据 m(m= 2n1). 3.如果上述规则都不满足,则不做操作。 输入格式 一行字符串,包含使用单个空格隔开的正整数,如 “5 6 7 8”,左边的数字先入栈。 输出格式 最终栈中存留的元素值,元素值使用单个空格隔开,如 “8 7 6 5”,从左至右依次为栈顶至栈底的数字。 以“10 20 50 80 1 1”为例,依次压入“10” “20” “50” 都不满足规则一和二,当压入“80”时,判断出80=10+20+50,满足规则二,于是 10 20 50 80 全部出栈,压入m=2*80=160。压入两个“1”,压入第二个“1”时,发现满足规则一,两个“1”出栈,压入m=2*1=2。(24点数解答 | 2024-10-28 18:51:00)245
- [字节豆包] #include <iostream> using namespace std; int main() { return 0; }食人魔战士们在日常训练的时候需要分组,酋长让食人魔战士们排成一队,然后从0开始进行报数,报到奇数的食人魔战士出队分成一组。食人魔酋长的第二个问题是:给出10名食人魔的能力值,报数为奇数的食人魔的能力值分别是多少? 输入: 十个整数,表示十名食人魔的能力值。 输出: 若干行,每行一个整数,表示报数为奇数的食人魔的能力值,输出能力值的顺序按照最初食人魔的序号顺序从小到大输出。 输入样例: 90 100 110 120 121 111 155 137 199 91 输出样例: 100 120 111 137 91(316点数解答 | 2025-11-22 19:44:15)11
- [字节豆包] using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace teachingmanagementsystem { class program { static void main(string[] args) { console.writeline("欢迎使用简易教学管理系统"); // 创建课程列表 list<course> courses = new list<course> { new course("数学"), new course("英语"), new course("物理") }; // 创建学生(419点数解答 | 2024-10-24 17:49:32)198
- [字节豆包] #include<stdio.h> int main() { int x; float cost; scanf("%d",&x); if(x<0) { printf("invalid value!"); } if(x<50) { cost=0.53*x; printf("cost = %.2f",cost); } if(x=50) { printf("cost = 26.50"); } if(x>50) { cost=(x-50)*0.58+26.50; printf("cost = %.2f",cost); } return 0; }(242点数解答 | 2024-11-05 09:31:52)193
- [字节豆包] c++ using namespace std;要有 不要注释 求a/b的结果。 已知a,b为10^8范围内的非负整数,求a/b保留前n位小数商的结果。(127点数解答 | 2025-09-26 19:15:23)25