結果
| 問題 | No.391 CODING WAR |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-23 10:41:29 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 1,598 bytes |
| 記録 | |
| コンパイル時間 | 2,929 ms |
| コンパイル使用メモリ | 247,336 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-23 10:41:34 |
| 合計ジャッジ時間 | 4,167 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, p, n) for (ll i = p; i < (ll)(n); i++)
#define rep2(i, p, n) for (ll i = p; i >= (ll)(n); i--)
using namespace std;
using ll = long long;
using ld = long double;
const double pi = 3.141592653589793;
const long long inf = 2 * 1e9;
const long long linf = 4 * 1e18;
const ll mod1 = 1000000007;
const ll mod2 = 998244353;
template <class T>
inline bool chmax(T &a, T b)
{
if (a < b)
{
a = b;
return 1;
}
return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
if (a > b)
{
a = b;
return 1;
}
return 0;
}
template <class T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
#include <atcoder/all>
using namespace atcoder;
using mint1 = modint1000000007;
using mint2 = modint998244353;
vector<pair<ll, ll>> base = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
void solve()
{
ll N, M;
cin >> N >> M;
mint1 ans = 0, C = 1;
rep(i, 0, M)
{
ll P = M - i;
mint1 temp = 1, temp2 = P;
ll B = 1;
rep(i, 0, 50)
{
if (B & N)
{
temp *= temp2;
}
temp2 *= temp2;
B *= 2;
}
temp *= C;
if (i % 2 == 0)
{
ans += temp;
}
else
{
ans -= temp;
}
C *= M - i;
C /= i + 1;
}
cout << ans.val() << endl;
}
int main()
{
//////////////////
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
//////////////////
solve();
}