結果

問題 No.2947 Sing a Song
ユーザー pessimist
提出日時 2024-10-25 22:04:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 193,016 KB
最終ジャッジ日時 2025-02-24 23:25:57
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(nullptr)->sync_with_stdio(false);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
  #endif
  int _N; cin >> _N;
  string S, T; cin >> S >> T;
  const int N = S.size();
  const int M = T.size();
  for(int i = 0; i < _N; ++i){
    int x; cin >> x;
    long long max_cnt = 0;
    for(long long y = 0; x >= y * M ;++y){
      if((x - y * M) % N == 0){
        max_cnt = x - y * M;
        max_cnt /= N;
        break;
      }
    }
    for(int t = 0; t < max_cnt; ++t) cout << S << ' ';
    for(int t = 0; t < (x - max_cnt * N) / M; ++t) cout << T << ' ';
    cout << '\n';
  }
  return 0;
}
0