gdhJHDadAD1
从 Trac 迁移的文章
这是从旧校内 Wiki 迁移的文章,可能存在一些样式问题,您可以向 memset0 反馈。
原文章内容如下:
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int p = 1'000'000'007;
int Qpow(int a, int b) {
int ret = 1;
while(b) {
if (b & 1) ret = 1ll * a * ret % p;
b >>= 1;
a = 1ll * a * a % p;
}
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);
string x0;
cin >> x0;
LL cur = 0;
for (int i : x0) {
cur = 1ll * cur * 10 + (i - '0');
cur %= p;
}
int q;
cin >> q;
LL inv = Qpow(10, mod - 2);
while(q--) {
string op;
int d;
cin >> op;
if (op[0] == '+') {
cin >> d;
cur = 1ll * cur * 10 + d;
cur %= p;
} else {
cur = cur - (x0.back() - '0') + p;
cur = cur * inv;
cur %= p;
}
cout << cur << '\n';
}
}
#include
using namespace std;
using LL = long long;
constexpr int p = 1'000'000'007;
int Qpow(int a, int b) {
int ret = 1;
while(b) {
if (b & 1) ret = 1ll * a * ret % p;
b >>= 1;
a = 1ll * a * a % p;
}
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);
string x0;
cin >> x0;
LL cur = 0;
for (int i : x0) {
cur = 1ll * cur * 10 + (i - '0');
cur %= p;
}
int q;
cin >> q;
LL inv = Qpow(10, mod - 2);
while(q--) {
string op;
int d;
cin >> op;
if (op[0] == '+') {
cin >> d;
cur = 1ll * cur * 10 + d;
cur %= p;
} else {
cur = cur - (x0.back() - '0') + p;
cur = cur * inv;
cur %= p;
}
cout << cur << '\n';
}
}
附加文件
- AAC_statements.pdf by SSerxhs