結果
問題 | No.1651 Removing Cards |
ユーザー | Focus_Sash |
提出日時 | 2021-08-20 22:25:58 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 4,472 bytes |
コンパイル時間 | 4,700 ms |
コンパイル使用メモリ | 264,320 KB |
実行使用メモリ | 11,628 KB |
最終ジャッジ日時 | 2024-10-14 04:20:36 |
合計ジャッジ時間 | 8,492 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 7 ms
5,352 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 27 ms
5,248 KB |
testcase_10 | AC | 26 ms
5,248 KB |
testcase_11 | AC | 28 ms
5,248 KB |
testcase_12 | AC | 28 ms
5,248 KB |
testcase_13 | AC | 28 ms
5,248 KB |
testcase_14 | AC | 28 ms
5,248 KB |
testcase_15 | AC | 58 ms
11,620 KB |
testcase_16 | AC | 56 ms
11,592 KB |
testcase_17 | AC | 59 ms
11,628 KB |
testcase_18 | AC | 58 ms
11,624 KB |
testcase_19 | AC | 57 ms
11,628 KB |
testcase_20 | AC | 57 ms
11,492 KB |
testcase_21 | AC | 58 ms
11,624 KB |
testcase_22 | AC | 43 ms
11,492 KB |
testcase_23 | AC | 29 ms
5,248 KB |
testcase_24 | AC | 17 ms
5,248 KB |
testcase_25 | AC | 42 ms
11,620 KB |
testcase_26 | AC | 42 ms
11,492 KB |
testcase_27 | AC | 58 ms
11,500 KB |
testcase_28 | AC | 58 ms
11,496 KB |
testcase_29 | AC | 56 ms
11,500 KB |
testcase_30 | AC | 57 ms
11,620 KB |
testcase_31 | AC | 58 ms
11,500 KB |
testcase_32 | AC | 24 ms
5,248 KB |
testcase_33 | AC | 23 ms
5,248 KB |
testcase_34 | AC | 24 ms
5,248 KB |
ソースコード
#include "bits/stdc++.h" #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using vl = vector<long long>; using pl = pair<long long, long long>; using PQ = priority_queue<long long>; using PQR = priority_queue<long long, vector<long long>, greater<>>; struct edge {long long to;long long cost;edge(long long t,long long c):to(t),cost(c){}}; using Graph = vector<vector<long long>>; using WGraph = vector<vector<edge>>; constexpr int dx[8]{1,0,-1,0,1,1,-1,-1}; constexpr int dy[8]{0,1,0,-1,1,-1,1,-1}; #define rep(i, n) for(long long (i) = 0; (i) < (n); (i)++) #define all(v) (v).begin(), (v).end() #define pb emplace_back #define V vector #define uniquify(vec) sort(all(vec)); (vec).erase(std::unique((vec).begin(), (vec).end()), (vec).end()) constexpr long long MOD1 = 1e9 + 7; constexpr long long MOD9 = 998244353; constexpr long long INF = MOD1*MOD1+1; constexpr long long LL_MAX = std::numeric_limits<long long>::max(); long long safe_mod(long long n, long long m){if(n >= 0) {return n % m;} else return (n%m + m)%m;} __int128 div_ceil(__int128 a, __int128 b){return (a + b - 1) / b;} long long DIG(long long x, long long d){ll ret=0;while(x){x/=d;ret++;}return ret;} long long pw(long long x,long long n) {ll ret=1;while(n>0){if(n&1){ret=ret*x;}if(n>>=1){x=x*x;}}return ret;} template<typename T> T SUM(const vector<T> &v){T ret{};return(accumulate(all(v), ret));} template<typename T> T pwmod(T x, long long n, long long m) {T ret=1;while(n>0){if(n&1)ret=ret*x%m;x=x*x%m;n>>=1;}return ret%m;} template<typename T> void rsort(vector<T> &v) {sort(all(v), greater<T>());} template<typename T> bool chmax(T &a,const T& b) {if(a<b){a=b;return true;}return false;} template<typename T> bool chmin(T &a,const T& b) {if(a>b){a=b;return true;}return false;} template<typename T> void fin(const T &a) {cout << a << '\n';exit(0);} template<typename T, typename S> pair<T, S> mp(const T &a, const S &b){return make_pair(a, b);} template<typename T> void unique(vector<T> &a){sort(all(a)); a.erase(std::unique(a.begin(), a.end()), a.end());} template<typename T> vector<int> compress(vector<T> &a){ int n = a.size(); vector<int> ret(n); vector<T> temp = a; unique(a); for(int i = 0; i < n; i++) ret[i] = lower_bound(a.begin(), a.end(), temp[i]) - a.begin(); return ret; } std::ostream &operator<<(std::ostream& os, const modint1000000007 &m){ os << m.val(); return os; } std::ostream &operator<<(std::ostream& os, const modint998244353 &m){ os << m.val(); return os; } template<typename T, typename S> std::ostream &operator<<(std::ostream& os, const pair<T, S> &p){ os << "(" << p.first << ", " << p.second << ")"; return os; } template <typename T> std::ostream &operator<<(std::ostream& os, const vector<T> &v){ int n = v.size(); os << "["; for(int i = 0; i < n; i++){ if(i == n - 1) os << v[i]; else os << v[i] << ", "; } os << "]"; return os; } template <typename T, typename S> std::ostream &operator<<(std::ostream& os, const map<T, S> &mp){ for(auto iter = mp.begin(); iter != mp.end(); iter++){ os << "(" << iter->first << ", " << iter->second << ")" << " "; } return os; } template <typename T> std::ostream &operator<<(std::ostream& os, const set<T> &s){ os << "{"; for(auto c : s) os << c << " "; os << "}"; return os; } //#define LOCAL #ifdef LOCAL #define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl #else #define dump(x) true #endif //using mint = modint1000000007; //using mint = modint998244353; void solve(){ ll k, q; cin >> k >> q; /* for(ll n = 1; n <= 200; n++){ vl a(n); iota(all(a), 1); while(a.size() >= 2){ //dump(a); vl b; for(ll i = 0; i < a.size(); i++){ if(i % k == 0) continue; b.pb(a[i]); } swap(a, b); } cout << n << '\n'; cout << a << '\n'; cout << '\n'; }*/ V<__int128> list; __int128 a = 1; list.pb(a); for(ll i = 2; a < 1e18; i++){ a = div_ceil(a * k, k-1); list.pb(a); } rep(_, q){ ll n; cin >> n; ll id = upper_bound(all(list), n) - list.begin(); cout << (ll)list[id-1] << '\n'; } } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); solve(); return 0; }