結果
| 問題 |
No.3002 多項式の割り算 〜easy〜
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-19 22:54:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 3,520 bytes |
| コンパイル時間 | 3,389 ms |
| コンパイル使用メモリ | 247,000 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-19 22:54:18 |
| 合計ジャッジ時間 | 4,879 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
// #define saisumith770
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
// clang-format off
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '[' << p.first << ',' << p.second << ']'; }
template <typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v){string sep;for (const T &x : v){os << sep << x, sep = ' ';}return os;}
#define PI 3.141592653589793238462
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define nline '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool is_prime(ll a){for (ll i = 2; i <= sqrt(a); i++){if (a % i == 0)return false;} return true;}
ll gcd(ll a, ll b){if (b == 0){return a;}if (b > a){return gcd(b, a);}return gcd(b, a % b);}
void extendgcd(ll a, ll b, ll *v){if (b == 0){v[0] = 1;v[1] = 10;v[2] = a;return;}extendgcd(b, a % b, v);ll x = v[1];v[1] = v[0] - v[1] * (a / b);v[0] = x;return;} // pass an arry of size1 3
//-------------Modular Arithemetics----------------------
ll mod_add(ll a, ll b, ll m){a = a % m;b = b % m;return (((a + b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m){a = a % m;b = b % m;return (((a - b) % m) + m) % m;}
ll mod_pow(ll a, ll b, ll mod){ll res = 1;while (b > 0){if (b & 1)res = (res * a) % mod;a = (a * a) % mod;b = b >> 1;}return res;}
ll mod_invprime(ll a, ll b) { return mod_pow(a, b - 2, b); }
ll mod_invnonprime(ll a, ll b){ll arr[3];extendgcd(a, b, arr);return mod_add(arr[0], 0, b);}
ll mod_inv(ll a, ll b){if (is_prime(b))return mod_invprime(a, b);return mod_invnonprime(a, b);}
ll mod_mul(ll a, ll b, ll m){a = a % m;b = b % m;return (((a * b) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m){a = a % m;b = b % m;return (mod_mul(a, mod_inv(b, m), m) + m) % m;}
ll getRandomNumber(ll l, ll r) {return uniform_int_distribution<ll>(l, r)(rng);}
//--------------------------------------------------------
vector<bool> sieve(ll n){vector<bool> vect(n + 1, 1);for (ll i = 2; i <= n; i++)if (vect[i]){for (ll j = i * i; j <= n; j += i)vect[j] = 0;}return vect;}
ll ncr(ll n, ll r){if (r > n) return 0; if (r == 0 || n == r) return 1; double res = 0; for (ll i = 0; i < r; i++) res += log(n - i) - log(i + 1); return (ll)round(exp(res));}
// clang-format on
bool stop(vector<int> p){
for(auto i=2;i<p.size();i++){
if(p[i]) return false;
}
return true;
}
int highestP(vector<int> p){
for(auto i=p.size()-1;i>=0;i--){
if(p[i]) {
return i;
}
}
return -1;
}
void solve()
{
int a,b;
cin>>a>>b;
vector<int> p(b+1,0);
p[b] = a;
while(!stop(p)){
int hi = highestP(p);
if(hi >= 2){
int buf = p[hi];
p[hi]-=buf;
p[hi-1]-=buf;
p[hi-2]-=buf;
}
}
cout<<p[1]<<' '<<p[0]<<nline;
}
int main()
{
#ifdef saisumith770
freopen("Logs.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
auto start1 = high_resolution_clock::now();
solve();
auto stop1 = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop1 - start1);
#ifdef saisumith770
cerr << "Time: " << duration.count() / 1000 << endl;
#endif
}