結果
| 問題 |
No.2845 Birthday Pattern in Two Different Calendars
|
| コンテスト | |
| ユーザー |
AngrySadEight
|
| 提出日時 | 2024-06-06 02:21:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 634 ms / 2,000 ms |
| コード長 | 1,265 bytes |
| コンパイル時間 | 627 ms |
| コンパイル使用メモリ | 73,908 KB |
| 最終ジャッジ日時 | 2025-02-21 19:26:49 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll my_gcd(ll a, ll b) {
ll ret = 0;
if (a < b) {
swap(a, b);
}
if (b == 0) {
ret = a;
} else {
ret = my_gcd(b, a % b);
}
return ret;
}
int main() {
ll T;
cin >> T;
while (T--) {
ll K, M, N;
cin >> K >> M >> N;
if (M == 1) {
cout << "No" << endl;
continue;
}
M--;
ll g = my_gcd(K, M);
ll one_loop = K / g;
ll max_ans = (one_loop / 2) * g;
if (N > max_ans) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
vector<ll> A(0);
for (ll i = 0; i < g; i++) {
ll now = i;
for (ll j = 0; j < one_loop / 2; j++) {
A.push_back(now);
now = (now + 2 * M) % K;
if (A.size() >= N) {
break;
}
}
}
for (ll i = 0; i < N; i++) {
cout << A[i] + 1;
if (i < N - 1) {
cout << " ";
}
}
cout << endl;
}
}
}
AngrySadEight