Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
106240 陈志轩 交流 C++ 通过 100 24 MS 340 KB 1529 2023-10-10 13:44:52

Tests(10/10):


#include<bits/stdc++.h> #define int long long using namespace std; int a[5005],b[5005]; vector <int> vec; void add(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 c(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 div(int x[],int y){ int maxl = 5000,s = 0; while (x[maxl] == 0 && maxl >= 1){ maxl--; } //cout<<maxl<<'\n'; for (int i = maxl;i >= 0;i--){ s = s * 10 + x[i]; vec.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'; } /* int maxl = 5000; while (b[maxl] == 0 && maxl >= 1){ maxl--; } for (int i = maxl;i >= 0;i--){ cout<<b[i]; } cout<<'\n'; */ add(a,b); } /* int maxl = 5000; while (a[maxl] == 0 && maxl >= 1){ maxl--; } for (int i = maxl;i >= 0;i--){ cout<<a[i]; } cout<<'\n'; */ c(a,n - 1); c(a,n - 2); /* maxl = 5000; while (a[maxl] == 0 && maxl >= 1){ maxl--; } for (int i = maxl;i >= 0;i--){ cout<<a[i]; } cout<<'\n'; */ div(a,2); bool qdl = true; for (int i = 0;i < vec.size();i++){ if (qdl && vec[i] == 0){ continue; } qdl = false; cout<<vec[i]; } //cout<<((n - 1) * (n - 2) / 2) * sum; return 0; }


测评信息: