結果
問題 | No.2969 ローラン単項式の微分 |
ユーザー |
|
提出日時 | 2024-11-29 21:45:37 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 6,409 bytes |
コンパイル時間 | 2,600 ms |
コンパイル使用メモリ | 249,004 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 21:45:41 |
合計ジャッジ時間 | 3,439 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
typedef long long ll;typedef long double ld;#include <bits/stdc++.h>using namespace std;// Union-Findstruct UnionFind {// core membervector<int> par;// constructorUnionFind() { }UnionFind(int n) : par(n, -1) { }void init(int n) { par.assign(n, -1); }// core methodsint root(int x) {if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool same(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x), y = root(y);if (x == y) return false;if (par[x] > par[y]) swap(x, y); // merge techniquepar[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}// get groupsvector<vector<int>> groups() {vector<vector<int>> member(par.size());for (int v = 0; v < (int)par.size(); ++v) {member[root(v)].push_back(v);}vector<vector<int>> res;for (int v = 0; v < (int)par.size(); ++v) {if (!member[v].empty()) res.push_back(member[v]);}return res;}// debugfriend ostream& operator << (ostream &s, UnionFind uf) {const vector<vector<int>> &gs = uf.groups();for (const vector<int> &g : gs) {s << "group: ";for (int v : g) s << v << " ";s << endl;}return s;}};// modinttemplate<int MOD> struct Fp {// inner valuelong long val;// constructorconstexpr Fp() : val(0) { }constexpr Fp(long long v) : val(v % MOD) {if (val < 0) val += MOD;}// getterconstexpr long long get() const {return val;}constexpr int get_mod() const {return MOD;}// comparison operatorsconstexpr bool operator == (const Fp &r) const {return this->val == r.val;}constexpr bool operator != (const Fp &r) const {return this->val != r.val;}// arithmetic operatorsconstexpr Fp& operator += (const Fp &r) {val += r.val;if (val >= MOD) val -= MOD;return *this;}constexpr Fp& operator -= (const Fp &r) {val -= r.val;if (val < 0) val += MOD;return *this;}constexpr Fp& operator *= (const Fp &r) {val = val * r.val % MOD;return *this;}constexpr Fp& operator /= (const Fp &r) {long long a = r.val, b = MOD, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b, swap(a, b);u -= t * v, swap(u, v);}val = val * u % MOD;if (val < 0) val += MOD;return *this;}constexpr Fp operator + () const { return Fp(*this); }constexpr Fp operator - () const { return Fp(0) - Fp(*this); }constexpr Fp operator + (const Fp &r) const { return Fp(*this) += r; }constexpr Fp operator - (const Fp &r) const { return Fp(*this) -= r; }constexpr Fp operator * (const Fp &r) const { return Fp(*this) *= r; }constexpr Fp operator / (const Fp &r) const { return Fp(*this) /= r; }// other operatorsconstexpr Fp& operator ++ () {++val;if (val >= MOD) val -= MOD;return *this;}constexpr Fp& operator -- () {if (val == 0) val += MOD;--val;return *this;}constexpr Fp operator ++ (int) {Fp res = *this;++*this;return res;}constexpr Fp operator -- (int) {Fp res = *this;--*this;return res;}friend constexpr istream& operator >> (istream &is, Fp<MOD> &x) {is >> x.val;x.val %= MOD;if (x.val < 0) x.val += MOD;return is;}friend constexpr ostream& operator << (ostream &os, const Fp<MOD> &x) {return os << x.val;}// other functionsconstexpr Fp pow(long long n) const {Fp res(1), mul(*this);while (n > 0) {if (n & 1) res *= mul;mul *= mul;n >>= 1;}return res;}constexpr Fp inv() const {Fp res(1), div(*this);return res / div;}friend constexpr Fp<MOD> pow(const Fp<MOD> &r, long long n) {return r.pow(n);}friend constexpr Fp<MOD> inv(const Fp<MOD> &r) {return r.inv();}};struct Eratos {vector<int> primes;vector<bool> isprime;vector<int> mebius;vector<int> min_factor;Eratos(int MAX) : primes(),isprime(MAX+1, true),mebius(MAX+1, 1),min_factor(MAX+1, -1) {isprime[0] = isprime[1] = false;min_factor[0] = 0, min_factor[1] = 1;for (int i = 2; i <= MAX; ++i) {if (!isprime[i]) continue;primes.push_back(i);mebius[i] = -1;min_factor[i] = i;for (int j = i*2; j <= MAX; j += i) {isprime[j] = false;if ((j / i) % i == 0) mebius[j] = 0;else mebius[j] = -mebius[j];if (min_factor[j] == -1) min_factor[j] = i;}}}// prime factorizationvector<pair<int,int>> prime_factors(int n) {vector<pair<int,int> > res;while (n != 1) {int prime = min_factor[n];int exp = 0;while (min_factor[n] == prime) {++exp;n /= prime;}res.push_back(make_pair(prime, exp));}return res;}// enumerate divisorsvector<int> divisors(int n) {vector<int> res({1});auto pf = prime_factors(n);for (auto p : pf) {int n = (int)res.size();for (int i = 0; i < n; ++i) {int v = 1;for (int j = 0; j < p.second; ++j) {v *= p.first;res.push_back(res[i] * v);}}}return res;}};signed main(){ll n,m;std::cin >> n>>m;if(n==0||m==0){std::cout << "No" << std::endl;return 0;}else{std::cout << "Yes" << std::endl;}std::cout << n*m<<" "<<m-1 << std::endl;}