結果
| 問題 |
No.823 Many Shifts Easy
|
| コンテスト | |
| ユーザー |
gazelle
|
| 提出日時 | 2019-04-26 22:15:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,153 bytes |
| コンパイル時間 | 1,124 ms |
| コンパイル使用メモリ | 113,536 KB |
| 最終ジャッジ日時 | 2025-01-07 03:13:20 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#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;
if(i != n) ans += (i * (k * (k - 1) / 2) % MOD) * tmp2; ans %= MOD;
}
cout << ans << endl;
return 0;
}
/* --------------------------------------- */
gazelle