結果

問題 No.3455 N-beatsu
コンテスト
ユーザー rinrion
提出日時 2026-02-28 14:15:38
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,215 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,239 ms
コンパイル使用メモリ 249,644 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-02-28 14:15:45
合計ジャッジ時間 5,365 ms
ジャッジサーバーID
(参考情報)
judge4 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vp = vector<pair<int, int>>;

#define rep(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define repr(i, s, n) for (int i = (s); i >= (int)(n); --i)
#define sz(x) ((int)(x).size())

constexpr int INFI = 1001001001;
constexpr ll INFL = (1LL << 60);

string to_string(long long x) {
	if (x == 0) return "0";
	string res;
	bool negative = false;
	if (x < 0) {
		negative = true;
		x = -x;
	}
	while (x > 0) {
		res += '0' + (x % 10);
		x /= 10;
	}
	if (negative) res += '-';
	reverse(res.begin(), res.end());
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, q;
	cin >> n >> q;
	vi a (q);
	rep(i, 0, q){
		cin >> a[i];
	}
	string s = to_string(n);

	rep (i, 0, q){
		bool jdg = 1;
		int x = a[i];
		string t = to_string(x);
		int idx = t.find(s) == string::npos ? -1 : s.find(s);
		if(x % n == 0 || idx != -1){
			cout << (jdg ? "Yes" : "No") << endl;
		}
		else{
			jdg = 0;
			cout << (jdg ? "Yes" : "No") << endl;
		}
	}

	return 0;
}
0