結果

問題 No.2416 vs Slime
ユーザー yurina256
提出日時 2023-08-12 13:49:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 6,689 bytes
コンパイル時間 4,403 ms
コンパイル使用メモリ 237,996 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-19 16:16:57
合計ジャッジ時間 5,275 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define length size()
#define int long long
#define ll long long
constexpr ll inf = 1001001001001001001ll;
constexpr ll mod = /* 1000000007*/ 998244353;
constexpr double pi = 3.141592653589793;
//
//cout << std::setprecision(12);
//imos
void to_ruiseki(vector<int> &vec){
for(int i=1;i<(int)vec.size();i++){
vec[i] += vec[i-1];
}
}
void to_2druiseki(vector<vector<int>> &vec){
rep(i,vec.size()){
rep(j,vec[0].size()){
int s = 0;
if(i!=0) s += vec[i-1][j];
if(j!=0) s += vec[i][j-1];
if(i!=0 && j!=0) s -= vec[i-1][j-1];
s += vec[i][j];
vec[i][j] = s;
}
}
}
//modpow(a,n,mod)
int modpow(int a, int n, int mod) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
//
vector<pair<int,int>> p_fact(int N) {
vector<pair<int,int>> res;
for (int a = 2; a * a <= N; ++a) {
if (N % a != 0) continue;
int ex = 0; //
//
while (N % a == 0) {
++ex;
N /= a;
}
// push
res.push_back({a, ex});
}
//
if (N != 1) res.push_back({N, 1});
return res;
}
//ctoi
int ctoi(const char c){
switch(c){
case '0': return 0;
case '1': return 1;
case '2': return 2;
case '3': return 3;
case '4': return 4;
case '5': return 5;
case '6': return 6;
case '7': return 7;
case '8': return 8;
case '9': return 9;
default : throw runtime_error("hoge");
}
}
//max
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
//min
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//print
void print() { cout << '\n'; }
template<typename T>
void print(const T &t) { cout << t << '\n'; }
template<typename Head, typename... Tail>
void print(const Head &head, const Tail &... tail) {
cout << head << ' ';
print(tail...);
}
//join
template<typename T> string join(vector<T> &vec ,const string &sp){
int si = vec.length;
if(si==0){
return "";
}else{
stringstream ss;
rep(i,si-1){
ss << vec[i] << sp;
}
ss << vec[si - 1];
return ss.str();
}
}
//
int tree_diameter(vector<vector<int>> &vec){
//0-indexed
queue<pair<int,int>> que;
vector<bool> is_searched(vec.size(),false);
que.push(make_pair(0,0));
int max_d = 0;
int max_e = 0;
while(!que.empty()){
int e = que.front().first;
int distance = que.front().second;
is_searched[e] = true;
if(max_d<distance){
max_d = distance;
max_e = e;
}
que.pop();
rep(i,vec[e].size()){
if(!is_searched[vec[e][i]]){
que.push( make_pair( vec[e][i], distance + 1 ) );
}
}
}
fill(is_searched.begin(),is_searched.end(),false);
que.push(make_pair(max_e,0));
max_d = 0;
max_e = 0;
while(!que.empty()){
int e = que.front().first;
int distance = que.front().second;
is_searched[e] = true;
if(max_d<distance){
max_d = distance;
max_e = e;
}
que.pop();
rep(i,vec[e].size()){
if(!is_searched[vec[e][i]]){
que.push( make_pair( vec[e][i], distance + 1 ) );
}
}
}
return max_d;
}
//uf :root(x) :issame(x,y) :unite(x,y) :size(x)
int getlongpath(vector<vector<int>> &vec,int st){
queue<pair<int,int>> que;
vector<bool> is_searched(vec.size(),false);
is_searched[st] = true;
que.push(make_pair(st,0));
int max_d = 0;
int max_e = 0;
while(!que.empty()){
int e = que.front().first;
int distance = que.front().second;
if(max_d<distance){
max_d = distance;
max_e = e;
}
que.pop();
rep(i,vec[e].size()){
if(!is_searched[vec[e][i]]){
que.push( make_pair( vec[e][i], distance + 1 ) );
is_searched[vec[e][i]] = true;
}
}
}
fill(is_searched.begin(),is_searched.end(),false);
que.push(make_pair(max_e,0));
return max_d;
}
struct UnionFind {
vector<int> par, rank, siz;
//
UnionFind(int n) : par(n,-1), rank(n,0), siz(n,1) { }
//
int root(int x) {
if (par[x]==-1) return x; // x x
else return par[x] = root(par[x]); //
}
// x y (= )
bool issame(int x, int y) {
return root(x)==root(y);
}
// x y
bool unite(int x, int y) {
int rx = root(x), ry = root(y); // x y
if (rx==ry) return false; //
// union by rank
if (rank[rx]<rank[ry]) swap(rx, ry); // ry rank
par[ry] = rx; // ry rx
if (rank[rx]==rank[ry]) rank[rx]++; // rx rank 調
siz[rx] += siz[ry]; // rx siz 調
return true;
}
// x
int size(int x) {
return siz[root(x)];
}
};
vector<pair<long long, long long> > prime_factorize(long long N) {
vector<pair<long long, long long> > res;
for (long long a = 2; a * a <= N; ++a) {
if (N % a != 0) continue;
long long ex = 0; //
//
while (N % a == 0) {
++ex;
N /= a;
}
// push
res.push_back({a, ex});
}
//
if (N != 1) res.push_back({N, 1});
return res;
}
int e(){
return inf;
}
int op(int a,int b){
return min(a,b);
}
int h,w,a;
void t_print(vector<int> vec){
rep(i,h){
rep(j,w){
cout << vec[i*h+j] << " ";
}
cout << endl;
}
cout << endl;
}
signed main(void){
int h,a;
cin >> h >> a;
int sum = 0;
int k = 1;
while(h!=0){
sum += k;
k *= 2;
h /= a;
}
print(sum);
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0