結果
| 問題 |
No.1671 Permutation Tour
|
| ユーザー |
ぷら
|
| 提出日時 | 2023-08-04 08:33:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,084 bytes |
| コンパイル時間 | 996 ms |
| コンパイル使用メモリ | 131,972 KB |
| 最終ジャッジ日時 | 2025-02-15 21:52:46 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 |
ソースコード
#include <string.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
constexpr int mod = 1000000007;
long long modpow(long long a,long long b) {
long long ans = 1;
while(b) {
if(b & 1) {
(ans *= a) %= mod;
}
(a *= a) %= mod;
b /= 2;
}
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
int ans = 0;
ans += 1ll*N*(N-1)/2%mod*N%mod;
ans += mod-1ll*(N-1)*N%mod*(2*N-1)%mod*modpow(6,mod-2)%mod;
ans %= mod;
ans = 2ll*ans%mod;
cout << ans*modpow(N-1,mod-2)%mod << "\n";
}
ぷら