This commit is contained in:
xtex 2024-03-02 13:17:50 +08:00
parent 726da21d35
commit ab642fda3c
Signed by: xtex
GPG key ID: B918086ED8045B91
9 changed files with 297 additions and 39 deletions

View file

@ -1,30 +0,0 @@
#include <stdio.h>
__uint128_t S(unsigned long long n) {
__uint128_t a, i;
a = 1;
i = 1;
for (; i <= n; i++) {
a *= i;
}
return a;
}
int main() {
unsigned long long n, i = 1;
__int128_t sum = 0;
scanf("%lld", &n);
for (; i <= n; i++) {
sum += S(i);
}
char buf[100];
int ptr = 98;
buf[99] = 0;
while (sum > 0) {
buf[ptr] = '0' + (((unsigned int)sum) % 10);
sum /= 10;
ptr--;
}
printf("%s\n", &buf[ptr + 1]);
return 0;
}

162
luogu/P1009.cc Normal file
View file

@ -0,0 +1,162 @@
#include <bits/stdc++.h>
struct BigIntTiny {
int sign;
std::vector<int> v;
BigIntTiny() : sign(1) {}
BigIntTiny(const std::string &s) { *this = s; }
BigIntTiny(int v) {
char buf[21];
sprintf(buf, "%d", v);
*this = buf;
}
void zip(int unzip) {
if (unzip == 0) {
for (int i = 0; i < (int)v.size(); i++)
v[i] = get_pos(i * 4) + get_pos(i * 4 + 1) * 10 +
get_pos(i * 4 + 2) * 100 + get_pos(i * 4 + 3) * 1000;
} else
for (int i = (v.resize(v.size() * 4), (int)v.size() - 1), a; i >= 0; i--)
a = (i % 4 >= 2) ? v[i / 4] / 100 : v[i / 4] % 100,
v[i] = (i & 1) ? a / 10 : a % 10;
setsign(1, 1);
}
int get_pos(unsigned pos) const { return pos >= v.size() ? 0 : v[pos]; }
BigIntTiny &setsign(int newsign, int rev) {
for (int i = (int)v.size() - 1; i > 0 && v[i] == 0; i--)
v.erase(v.begin() + i);
sign = (v.size() == 0 || (v.size() == 1 && v[0] == 0))
? 1
: (rev ? newsign * sign : newsign);
return *this;
}
std::string to_str() const {
BigIntTiny b = *this;
std::string s;
for (int i = (b.zip(1), 0); i < (int)b.v.size(); ++i)
s += char(*(b.v.rbegin() + i) + '0');
return (sign < 0 ? "-" : "") + (s.empty() ? std::string("0") : s);
}
bool absless(const BigIntTiny &b) const {
if (v.size() != b.v.size())
return v.size() < b.v.size();
for (int i = (int)v.size() - 1; i >= 0; i--)
if (v[i] != b.v[i])
return v[i] < b.v[i];
return false;
}
BigIntTiny operator-() const {
BigIntTiny c = *this;
c.sign = (v.size() > 1 || v[0]) ? -c.sign : 1;
return c;
}
BigIntTiny &operator=(const std::string &s) {
if (s[0] == '-')
*this = s.substr(1);
else {
for (int i = (v.clear(), 0); i < (int)s.size(); ++i)
v.push_back(*(s.rbegin() + i) - '0');
zip(0);
}
return setsign(s[0] == '-' ? -1 : 1, sign = 1);
}
bool operator<(const BigIntTiny &b) const {
return sign != b.sign ? sign < b.sign
: (sign == 1 ? absless(b) : b.absless(*this));
}
bool operator==(const BigIntTiny &b) const {
return v == b.v && sign == b.sign;
}
BigIntTiny &operator+=(const BigIntTiny &b) {
if (sign != b.sign)
return *this = (*this) - -b;
v.resize(std::max(v.size(), b.v.size()) + 1);
for (int i = 0, carry = 0; i < (int)b.v.size() || carry; i++) {
carry += v[i] + b.get_pos(i);
v[i] = carry % 10000, carry /= 10000;
}
return setsign(sign, 0);
}
BigIntTiny operator+(const BigIntTiny &b) const {
BigIntTiny c = *this;
return c += b;
}
void add_mul(const BigIntTiny &b, int mul) {
v.resize(std::max(v.size(), b.v.size()) + 2);
for (int i = 0, carry = 0; i < (int)b.v.size() || carry; i++) {
carry += v[i] + b.get_pos(i) * mul;
v[i] = carry % 10000, carry /= 10000;
}
}
BigIntTiny operator-(const BigIntTiny &b) const {
if (b.v.empty() || b.v.size() == 1 && b.v[0] == 0)
return *this;
if (sign != b.sign)
return (*this) + -b;
if (absless(b))
return -(b - *this);
BigIntTiny c;
for (int i = 0, borrow = 0; i < (int)v.size(); i++) {
borrow += v[i] - b.get_pos(i);
c.v.push_back(borrow);
c.v.back() -= 10000 * (borrow >>= 31);
}
return c.setsign(sign, 0);
}
BigIntTiny operator*(const BigIntTiny &b) const {
if (b < *this)
return b * *this;
BigIntTiny c, d = b;
for (int i = 0; i < (int)v.size(); i++, d.v.insert(d.v.begin(), 0))
c.add_mul(d, v[i]);
return c.setsign(sign * b.sign, 0);
}
BigIntTiny operator/(const BigIntTiny &b) const {
BigIntTiny c, d;
BigIntTiny e = b;
e.sign = 1;
d.v.resize(v.size());
double db =
1.0 / (b.v.back() + (b.get_pos((unsigned)b.v.size() - 2) / 1e4) +
(b.get_pos((unsigned)b.v.size() - 3) + 1) / 1e8);
for (int i = (int)v.size() - 1; i >= 0; i--) {
c.v.insert(c.v.begin(), v[i]);
int m = (int)((c.get_pos((int)e.v.size()) * 10000 +
c.get_pos((int)e.v.size() - 1)) *
db);
c = c - e * m, c.setsign(c.sign, 0), d.v[i] += m;
while (!(c < e))
c = c - e, d.v[i] += 1;
}
return d.setsign(sign * b.sign, 0);
}
BigIntTiny operator%(const BigIntTiny &b) const {
return *this - *this / b * b;
}
bool operator>(const BigIntTiny &b) const { return b < *this; }
bool operator<=(const BigIntTiny &b) const { return !(b < *this); }
bool operator>=(const BigIntTiny &b) const { return !(*this < b); }
bool operator!=(const BigIntTiny &b) const { return !(*this == b); }
};
BigIntTiny S(unsigned long long n) {
BigIntTiny a(1);
unsigned long long i = 1;
for (; i <= n; i++) {
a = a * i;
}
return a;
}
int main() {
unsigned long long n, i = 1;
BigIntTiny sum;
scanf("%lld", &n);
for (; i <= n; i++) {
sum = sum + S(i);
}
std::cout << sum.to_str();
return 0;
}

View file

@ -1,14 +1,14 @@
Metadata-Version: 1
Problem-Id: P1009
Record-Id: 117901788
Timestamp: 1690551244
Status: Unaccepted
Score: 50/100
Language: C
Record-Id: 148434630
Timestamp: 1708943315
Status: Accepted
Score: 100/100
Language: C++14 (GCC 9)
Test-Result:
Subtask: 0
Case: 0 AC 3 ms 808 KiB ok accepted
Case: 1 AC 2 ms 808 KiB ok accepted
Case: 2 WA 3 ms 808 KiB wrong answer On line 1 column 11, read 2, expected 4.
Case: 3 WA 3 ms 808 KiB wrong answer Too short on line 1.
Case: 0 AC 3 ms 556 KiB ok accepted
Case: 1 AC 3 ms 552 KiB ok accepted
Case: 2 AC 3 ms 672 KiB ok accepted
Case: 3 AC 4 ms 568 KiB ok accepted

18
luogu/P1024.cc Normal file
View file

@ -0,0 +1,18 @@
#include <bits/stdc++.h>
int main() {
using namespace std;
cin.tie(0);
double a, b, c, d;
cin >> a >> b >> c >> d;
for (double x = -100.0; x <= 100.0; x += 0.001) {
double x2 = x * x;
double x3 = x2 * x;
if (fabs(x3 * a + x2 * b + x * c + d) < 0.0001)
cout << fixed << setprecision(2) << x << " ";
}
putchar('\n');
return 0;
}

14
luogu/P1024.txt Normal file
View file

@ -0,0 +1,14 @@
Metadata-Version: 1
Problem-Id: P1024
Record-Id: 148435618
Timestamp: 1708944035
Status: Accepted
Score: 100/100
Language: C++14 (GCC 9)
Test-Result:
Subtask: 0
Case: 0 AC 4 ms 552 KiB ok accepted
Case: 1 AC 4 ms 556 KiB ok accepted
Case: 2 AC 4 ms 580 KiB ok accepted
Case: 3 AC 4 ms 576 KiB ok accepted

34
luogu/P1143.cc Normal file
View file

@ -0,0 +1,34 @@
#include <bits/stdc++.h>
int main() {
using namespace std;
ios::sync_with_stdio(false);
cin.tie(0);
unsigned int n, m;
scanf("%u\n", &n);
unsigned int num = 0;
while (true) {
char c = getchar();
if (c == '\r' || c == '\n')
break;
if (c >= 'A')
c = c - 'A' + 10;
else
c = c ^ '0';
num = num * n + c;
}
scanf("%u", &m);
char buf[128];
unsigned i = 0;
while (num > 0) {
unsigned int b = num % m;
char c = b > 9 ? b + 'A' - 10 : b ^ '0';
buf[++i] = c;
num = num / m;
}
while (i > 0) {
putchar(buf[i--]);
}
putchar('\n');
return 0;
}

15
luogu/P1143.txt Normal file
View file

@ -0,0 +1,15 @@
Metadata-Version: 1
Problem-Id: P1143
Record-Id: 148534836
Timestamp: 1709029464
Status: Accepted
Score: 100/100
Language: C++14 (GCC 9)
Test-Result:
Subtask: 0
Case: 0 AC 4 ms 552 KiB ok accepted
Case: 1 AC 3 ms 552 KiB ok accepted
Case: 2 AC 3 ms 564 KiB ok accepted
Case: 3 AC 3 ms 568 KiB ok accepted
Case: 4 AC 3 ms 556 KiB ok accepted

10
luogu/P7540.cc Normal file
View file

@ -0,0 +1,10 @@
#include <bits/stdc++.h>
int main() {
unsigned int N;
scanf("%u", &N);
unsigned int ans;
ans = (N * (N + 1) / 2 * (N + 2));
printf("%u\n", ans);
return 0;
}

35
luogu/P7540.txt Normal file
View file

@ -0,0 +1,35 @@
Metadata-Version: 1
Problem-Id: P7540
Record-Id: 148433204
Timestamp: 1708942188
Status: Accepted
Score: 50/50
Language: C++14 (GCC 9)
Test-Result:
Subtask: 0
Case: 0 AC 3 ms 564 KiB ok accepted
Case: 1 AC 3 ms 556 KiB ok accepted
Case: 2 AC 3 ms 568 KiB ok accepted
Case: 3 AC 3 ms 556 KiB ok accepted
Case: 4 AC 3 ms 564 KiB ok accepted
Case: 5 AC 3 ms 560 KiB ok accepted
Case: 6 AC 3 ms 552 KiB ok accepted
Case: 7 AC 3 ms 668 KiB ok accepted
Case: 8 AC 4 ms 556 KiB ok accepted
Case: 9 AC 3 ms 556 KiB ok accepted
Case: 10 AC 3 ms 560 KiB ok accepted
Case: 11 AC 3 ms 556 KiB ok accepted
Case: 12 AC 3 ms 680 KiB ok accepted
Case: 13 AC 3 ms 612 KiB ok accepted
Case: 14 AC 3 ms 556 KiB ok accepted
Case: 15 AC 3 ms 568 KiB ok accepted
Case: 16 AC 3 ms 556 KiB ok accepted
Case: 17 AC 3 ms 556 KiB ok accepted
Case: 18 AC 3 ms 624 KiB ok accepted
Case: 19 AC 3 ms 556 KiB ok accepted
Case: 20 AC 3 ms 560 KiB ok accepted
Case: 21 AC 3 ms 556 KiB ok accepted
Case: 22 AC 3 ms 552 KiB ok accepted
Case: 23 AC 3 ms 604 KiB ok accepted
Case: 24 AC 3 ms 564 KiB ok accepted