結果
| 問題 | No.3455 N-beatsu |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-28 13:42:39 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 6,859 bytes |
| 記録 | |
| コンパイル時間 | 5,986 ms |
| コンパイル使用メモリ | 281,608 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-02-28 13:42:46 |
| 合計ジャッジ時間 | 6,596 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
//#include <bits/stdc++.h>
#include <algorithm>
#include <bit>
#include <cassert>
#include <charconv>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <ranges>
#include <set>
#include <span>
#include <stack>
#include <string>
#include <string_view>
#include <tuple>
#include <vector>
// #define OLD_JUDGE
#ifdef OLD_JUDGE
# define USE_ISTREAM
# define USE_OSTREAM
#else
# define USE_ISTREAM
# define USE_PRINT
#endif
#if defined(USE_ISTREAM) || defined(USE_OSTREAM)
# include <iomanip>
# include <iostream>
#endif
#ifdef USE_PRINT
# include <format>
# include <print>
#endif
namespace tomolatoon
{
using namespace std::views;
namespace rng = std::ranges;
#ifdef USE_ISTREAM
using std::cin;
#endif
#ifdef USE_OSTREAM
using std::cout;
using std::endl;
#endif
#ifdef USE_PRINT
using std::format;
using std::print;
using std::println;
template <class T>
void pr(T&& t)
{
print("{}", std::forward<T>(t));
}
template <class T>
void prn(T&& t)
{
println("{}", std::forward<T>(t));
}
#endif
using rng::subrange;
using std::array;
using std::deque;
using std::list;
using std::map;
using std::multimap;
using std::multiset;
using std::pair;
using std::queue;
using std::set;
using std::span;
using std::stack;
using std::string;
using std::string_view;
using std::tuple;
using std::vector;
template <class T>
using vec = vector<T>;
using uint = std::uint32_t;
using ull = std::uint64_t;
using ll = std::int64_t;
using std::size_t;
// clang-format off
using rng::all_of;
using rng::any_of;
#ifndef OLD_JUDGE
using rng::none_of;
using rng::contains;
using rng::contains_subrange;
#endif
using rng::for_each;
using rng::for_each_n;
using rng::find;
using rng::find_if;
using rng::find_if_not;
#ifndef OLD_JUDGE
using rng::find_last;
using rng::find_last_if;
using rng::find_last_if_not;
#endif
using rng::find_end;
using rng::find_first_of;
using rng::adjacent_find;
using rng::count;
using rng::count_if;
using rng::mismatch;
using rng::equal;
using rng::search;
using rng::search_n;
// clang-format on
using rng::sort;
using rng::stable_sort;
using rng::unique;
using rng::max_element;
using rng::min_element;
using rng::binary_search;
using rng::equal_range;
using rng::lower_bound;
using rng::upper_bound;
using rng::next_permutation;
using rng::prev_permutation;
using rng::begin;
using rng::distance;
using rng::end;
using rng::ssize;
using rng::swap;
using std::abs;
using std::midpoint;
using std::back_inserter;
using std::front_inserter;
using std::inserter;
using namespace std::placeholders;
void yn(bool f)
{
#ifdef USE_OSTREAM
cout << (f ? "Yes" : "No") << "\n";
#elifdef USE_PRINT
println("{}", (f ? "Yes" : "No"));
#endif
}
string yns(bool f)
{
return f ? "Yes" : "No";
}
// clang-format off
struct P
{
using type = ll;
type i;
type j;
P moved(type id, type jd) const { return {i + id, j + jd}; }
P moved(P pd) const { return moved(pd.i, pd.j); }
template <class T>
T& operator[](vec<vec<T>>& v) const { return v[i][j]; }
char& operator[](vec<string>& v) const { return v[i][j]; }
friend P operator+(const P& lhs, const P& rhs) { return lhs.moved(rhs); }
friend P operator-(const P& lhs, const P& rhs) { return lhs.moved(-rhs); }
P operator-() const { return P{-i, -j}; }
friend bool operator==(const P& lhs, const P& rhs) { return lhs.i == rhs.i && lhs.j == rhs.j; }
friend auto operator<=>(const P& lhs, const P& rhs) { return lhs.i != rhs.i ? lhs.i <=> rhs.i : lhs.j <=> rhs.j; }
ll L1() const { return std::abs(i) + std::abs(j); }
friend ll ip(const P& lhs, const P& rhs) { return lhs.i * rhs.i + lhs.j * rhs.j; }
};
const auto in_f = [](P::type h, P::type w) { return [=](P p) { return 0 <= p.i && p.i < h && 0 <= p.j && p.j < w; }; };
static const auto P4 = array<P, 4>{P{-1, 0}, P{ 0, -1}, P{ 1, 0}, P{ 0, 1}};
static const auto P8 = array<P, 8>{P{-1, 0}, P{-1, -1}, P{ 0, -1}, P{ 1, -1}, P{ 1, 0}, P{ 1, 1}, P{ 0, 1}, P{-1, 1}};
// clang-format on
ll pow(ll base, size_t n)
{
assert(not(base == 0 && n == 0));
if (n == 0) return 1;
if (n == 1) return base;
ll prev = pow(base, n / 2);
return prev * prev * (n % 2 ? base : 1);
}
ll pow(ll base, size_t n, ll mod)
{
assert(not(base == 0 && n == 0));
constexpr auto modf = [](ll x, ll mod) {
return (x % mod + mod) % mod;
};
if (base >= mod) base %= mod;
if (n == 0) return 1;
if (n == 1) return base;
ll prev = pow(base, n / 2);
ll pp = modf(prev * prev, mod);
return (n % 2 ? modf(pp * base, mod) : pp);
}
template <class T>
T shared_length_signed(T l1, T r1, T l2, T r2)
{
return rng::min(r1, r2) - rng::max(l1, l2);
}
template <class T>
T shared_length(T l1, T r1, T l2, T r2)
{
return rng::max(0, rng::min(r1, r2) - rng::max(l1, l2));
}
/// @brief ランレングス圧縮(RLE: Run Length Encoding)を行い,出力イテレータへ書き込む
/// @note vec<pair<T, size_t>>をreserveし,それのback_inserter(back_insert_iterator)を渡すことが想定される
/// @param r ランレングス圧縮したいrange
/// @param out 出力イテレータ
template <rng::forward_range R, std::output_iterator<std::pair<rng::range_value_t<R>, size_t>> I>
requires std::copyable<rng::range_value_t<R>> && std::equality_comparable<rng::range_value_t<R>>
void rle(R&& r, I out)
{
using pair = std::pair<rng::range_value_t<R>, size_t>;
auto it = begin(r);
auto e = end(r);
if (it == e)
{
return;
}
size_t size = 1;
rng::range_value_t<R> prev = *it;
++it;
for (; it != e; ++it)
{
if (*it == prev)
{
++size;
}
else
{
*out++ = pair(std::move(prev), size);
prev = *it;
size = 1;
}
}
*out++ = pair(std::move(prev), size);
}
namespace detail
{
template <size_t N>
struct get
{
template <class T>
// static
constexpr decltype(auto) operator()(T&& t) noexcept(noexcept(std::get<N>(t)))
{
return std::get<N>(t);
}
};
} // namespace detail
template <size_t N>
inline constexpr auto get = detail::get<N>{};
constexpr ll INF = 3e18;
} // namespace tomolatoon
namespace tomolatoon
{
void solve()
{
ll n, q;
cin >> n >> q;
for (auto i : iota(0, q))
{
ll x;
cin >> x;
string ns = std::to_string(n);
string xs = std::to_string(x);
yn(x % n == 0 || xs.contains(ns));
}
}
} // namespace tomolatoon
int main()
{
#ifdef USE_ISTREAM
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
#endif
#ifdef USE_OSTREAM
std::cout << std::fixed << std::setprecision(16);
#endif
tomolatoon::solve();
#ifdef USE_OSTREAM
std::cout << std::flush;
#endif
}