結果
問題 | No.2845 Birthday Pattern in Two Different Calendars |
ユーザー |
![]() |
提出日時 | 2024-08-23 22:21:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 945 bytes |
コンパイル時間 | 1,985 ms |
コンパイル使用メモリ | 198,700 KB |
最終ジャッジ日時 | 2025-02-23 23:58:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> using namespace std; //#include<atcoder/all> //using namespace atcoder; //typedef modint998244353 mint; typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) void solve(){ int k,m,n; cin >> k >> m >> n; vector<bool> seen(k); vector<pair<int,int>> ans; auto a = [&](int i){ return (i+m-1) % k; }; rep(i,0,n){ if(seen[i])continue; int x = i; while(true){ if (seen[x]) break; if (!seen[a(x)] && x != a(x)){ ans.push_back(pair(x,a(x))); seen[x] = 1; seen[a(x)] = 1; x = a(a(x)); }else{ seen[x] = 1; x = a(x); } } } if ((int)ans.size() >= n){ cout << "Yes\n"; rep(i,0,n){ cout << ans[i].first+1 << ' '; } cout << '\n'; }else{ cout << "No\n"; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while(t--) solve(); }