- 「FeOI Round 1」Journey
为什么会RE
- 2024-8-26 17:08:11 @
在洛谷上过了,为什么在这里会RE?
#include <iostream>
#include <cstdio>
typedef long long LL;
using namespace std;
void RD() {}
template<typename T, typename... U> void RD(T &x, U&... arg) {
x = 0; int f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
x *= f; RD(arg...);
}
const LL N = 2e7 + 5, mod = 1e9 + 7;
#define PRINT(x) cout << #x << " = " << x << "\n"
#define LF(i, __l, __r) for (int i = __l; i <= __r; i++)
#define RF(i, __r, __l) for (int i = __r; i >= __l; i--)
LL n, cnt;
LL a, b, c, g[N], ans;
LL f[N], num[N], prime[N];
bool vis[N];
void get(int n) {
f[1] = 1;
LF(i, 2, n) {
if (!vis[i]) prime[++cnt] = i, f[i] = 2, num[i] = 1;
LF(j, 1, cnt) {
int nx = i * prime[j];
if (nx > n) break;
vis[nx] = 1;
if (i % prime[j] == 0) {
num[nx] = num[i] + 1;
f[nx] = f[i] / num[nx] * (num[nx] + 1);
break;
}
num[nx] = 1; f[nx] = f[i] * 2;
}
}
}
int main() {
RD(n, a, b, c);
RD(g[n]);
RF(i, n - 1, 1) g[i] = (a * g[i + 1] % mod * g[i + 1] % mod + b * g[i + 1] % mod + c) % mod;
get(n);
LF(i, 1, n) f[i] += f[i - 1];
LF(i, 1, n) ans = (ans + f[i - 1] * (n - i + 1) % mod * g[i] % mod + n * (n - i + 1) % mod * g[i] % mod) % mod;
printf("%lld", ans);
return 0;
}
1 条评论
-
xht LV 3 @ 2024-8-29 2:49:04
两边编译器不同,主要原因还是你写出了 ub
- 1
信息
- ID
- 36
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 357
- 已通过
- 65
- 上传者