Submission #1857186
Source Code Expand
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <queue> #include <vector> #include <bitset> #include <string> #include <cmath> #include <set> #include <map> #define Rep(i, x, y) for (int i = x; i <= y; i ++) #define Dwn(i, x, y) for (int i = x; i >= y; i --) #define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex) #define ev g[i].y #define eps 1e-10 using namespace std; typedef long long ll; typedef double db; const int N = 1000005, mod = 1000000007; int n; ll f[N], k; int main() { scanf ("%d", &n); f[0] = 1, f[1] = n; Rep(i, 2, n) { if (i >= 3) k += f[i - 3]; f[i] = (f[i - 1] + (ll)(n - 1) * (n - 1) + (n - i + 1) + k) % mod; } printf("%lld\n", f[n]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Infinite Sequence |
User | hzt1 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 754 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 8064 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:25:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf ("%d", &n); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt |
All | 0_000.txt, 0_001.txt, max_1000000.txt, max_999745.txt, max_999880.txt, max_999999.txt, min_1.txt, rnd_14.txt, rnd_22.txt, rnd_25002.txt, rnd_2956.txt, rnd_3.txt, rnd_380467.txt, rnd_407774.txt, rnd_52228.txt, rnd_68.txt, rnd_804783.txt, rnd_85984.txt, rnd_894324.txt, rnd_93.txt, rnd_963981.txt, rnd_968416.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 6 ms | 6400 KB |
max_1000000.txt | AC | 8 ms | 8064 KB |
max_999745.txt | AC | 8 ms | 8064 KB |
max_999880.txt | AC | 9 ms | 8064 KB |
max_999999.txt | AC | 8 ms | 8064 KB |
min_1.txt | AC | 1 ms | 256 KB |
rnd_14.txt | AC | 1 ms | 256 KB |
rnd_22.txt | AC | 1 ms | 256 KB |
rnd_25002.txt | AC | 1 ms | 384 KB |
rnd_2956.txt | AC | 1 ms | 256 KB |
rnd_3.txt | AC | 1 ms | 256 KB |
rnd_380467.txt | AC | 5 ms | 4352 KB |
rnd_407774.txt | AC | 5 ms | 4352 KB |
rnd_52228.txt | AC | 2 ms | 640 KB |
rnd_68.txt | AC | 1 ms | 256 KB |
rnd_804783.txt | AC | 6 ms | 6528 KB |
rnd_85984.txt | AC | 2 ms | 896 KB |
rnd_894324.txt | AC | 7 ms | 7168 KB |
rnd_93.txt | AC | 1 ms | 256 KB |
rnd_963981.txt | AC | 8 ms | 7808 KB |
rnd_968416.txt | AC | 8 ms | 7808 KB |