結果

問題 No.2947 Sing a Song
コンテスト
ユーザー pengin_2000
提出日時 2024-10-25 21:50:27
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 720 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 211 ms
コンパイル使用メモリ 37,760 KB
最終ジャッジ日時 2026-02-22 12:04:01
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>
char s[200005], t[200005];
int a[200005];
int dp[200005];
int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s%s", s, t);
	int ss, tt;
	for (ss = 0; s[ss] != '\0'; ss++);
	for (tt = 0; t[tt] != '\0'; tt++);
	int i, j;
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < ss; i++)
		dp[i] = 0;
	for (; i < 200005; i++)
	{
		if (i % ss > 0)
		{
			if (i >= tt)
				dp[i] = dp[i - tt];
			else
				dp[i] = 0;
		}
		else
			dp[i] = i / ss;
	}
	for (i = 0; i < n; i++)
	{
		while (dp[a[i]] > 0)
		{
			printf("%s", s);
			a[i] -= ss;
			if (a[i] > 0)
				printf(" ");
		}
		while (a[i] > 0)
		{
			printf("%s", t);
			a[i] -= tt;
			if (a[i] > 0)
				printf(" ");
		}
		printf("\n");
	}
	return 0;
}
0