提出 #36690846


ソースコード 拡げる

#include<bits/stdc++.h>
#define MOD 1000000007
#define LL long long
using namespace std;
int mul(const int &a, const int &b)
{
	return 1LL * a * b % MOD;
}
void Inc(int &a, const int &b)
{
	((a += b) >= MOD) && (a -= MOD);
}
const int N = 1e6 + 5;
int n, f[N], sum;
int main()
{
	scanf("%d", &n);
	f[n] = n;
	f[n - 1] = mul(n, n);
	for(int i = n - 2; i >= 1; --i)
	{
		Inc(sum, f[i + 3]);
		f[i] = f[i + 1];
		Inc(f[i], mul(n - 1, n - 1));
		Inc(f[i], sum + i + 1);
	}
	printf("%d\n", f[1]);
	return 0;
}

提出情報

提出日時
問題 F - Infinite Sequence
ユーザ Schucking_Sattin
言語 C++ (GCC 9.2.1)
得点 1000
コード長 532 Byte
結果 AC
実行時間 15 ms
メモリ 7584 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 1000 / 1000
結果
AC × 2
AC × 22
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
0_000.txt AC 5 ms 3712 KiB
0_001.txt AC 13 ms 6160 KiB
max_1000000.txt AC 14 ms 7452 KiB
max_999745.txt AC 12 ms 7452 KiB
max_999880.txt AC 11 ms 7580 KiB
max_999999.txt AC 10 ms 7584 KiB
min_1.txt AC 2 ms 3664 KiB
rnd_14.txt AC 3 ms 3784 KiB
rnd_22.txt AC 4 ms 3772 KiB
rnd_25002.txt AC 3 ms 3712 KiB
rnd_2956.txt AC 2 ms 3776 KiB
rnd_3.txt AC 3 ms 3664 KiB
rnd_380467.txt AC 7 ms 5036 KiB
rnd_407774.txt AC 7 ms 5200 KiB
rnd_52228.txt AC 4 ms 3880 KiB
rnd_68.txt AC 2 ms 3672 KiB
rnd_804783.txt AC 12 ms 6908 KiB
rnd_85984.txt AC 5 ms 4048 KiB
rnd_894324.txt AC 15 ms 7164 KiB
rnd_93.txt AC 3 ms 3708 KiB
rnd_963981.txt AC 11 ms 7480 KiB
rnd_968416.txt AC 10 ms 7328 KiB