結果

問題 No.823 Many Shifts Easy
ユーザー gazellegazelle
提出日時 2019-04-26 22:12:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,142 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 116,004 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-16 14:39:03
合計ジャッジ時間 1,725 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
#include<cassert>
using namespace std;
using lint = long long;
using ld = long double;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(lint i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n, k;
	cin >> n >> k;
	lint tmp1 = 1, tmp2 = 1;
	REP(i, k) {
		tmp1 *= (n - 1 - i);
		tmp1 %= MOD;
	}
	REP(i, k - 2) {
		tmp2 *= (n - 2 - i);
		tmp2 %= MOD;
	}
	lint ans = 0;
	FOR(i, 1, n + 1) {
		ans += i * tmp1; ans %= MOD;
		ans += (i * (k * (k - 1) / 2) % MOD) * tmp2; ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}
/* --------------------------------------- */
0