Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
106475 wwzzzzzz 交流 C++ 通过 100 22 MS 352 KB 1025 2023-10-12 13:11:29

Tests(10/10):


#include<bits/stdc++.h> #define int long long using namespace std; int a[5005],b[5005]; vector <int> chx; void lcx(int x[],int y[]){ for (int i = 0;i <= 5000;i++){ x[i] += y[i]; x[i + 1] += (x[i] / 10); x[i] %= 10; } } void fkx(int x[],int y){ for (int i = 0;i <= 5000;i++){ x[i] *= y; if (i > 0){ x[i] += (x[i - 1] / 10); x[i - 1] %= 10; } } } void lhc(int x[],int y){ int maxl = 5000,s = 0; while (x[maxl] == 0 && maxl >= 1){ maxl--; } for (int i = maxl;i >= 0;i--){ s = s * 10 + x[i]; chx.push_back(s / y); s %= y; } } signed main(){ int n,sum = 0; cin>>n; for (int i = 1;i <= n;i++){ string x; //int a; cin>>x; memset(b,0,sizeof(b)); for (int j = 0;j < x.size();j++){ b[j] = x[x.size() - j - 1] - '0'; } lcx(a,b); } fkx(a,n - 1); fkx(a,n - 2); lhc(a,2); bool czx = true; for (int i = 0;i < chx.size();i++){ if (czx && chx[i] == 0){ continue; } czx = false; cout<<chx[i]; } return 0; }


测评信息: