結果

問題 No.2845 Birthday Pattern in Two Different Calendars
ユーザー n0ma_run0ma_ru
提出日時 2024-08-23 21:50:07
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,134 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 203,776 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-08-23 21:50:15
合計ジャッジ時間 5,200 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) v.begin(),v.end()
#define dbg(x) cerr << #x << ": " << (x) << endl;
template<class F, class S>
ostream& operator<<(ostream& os, pair<F,S>& p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<class Iter>
void print(Iter beg, Iter end) {
    for (Iter itr = beg; itr != end; ++itr) {
        cerr << *itr << ' ';
    }
    cerr << '\n';
}
inline bool naraba(bool a, bool b) { return (!a || b); }

int N,M,K;

void solve() {
    cin >> K >> M >> N;

    int D = gcd(K,M-1);
    int cnt = K/D/2 * D;

    if (cnt >= N) {
        cout << "Yes\n";
        int now = 0;
        vector<int> ans;
        for (int i = 0; i < K/D/2; ++i) {
            ans.push_back(now);
            now = (now + M-1) % K;
            now = (now + M-1) % K;
        }
        for (int i = 0; i < N; ++i) {
            int x = ans[i % ans.size()] + (i/ans.size()) + 1;
            cout << x+1 << " \n"[i==N-1];
        }
    } else {
        cout << "No\n";
    }
}

int main() {
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
}
0