結果

問題 No.207 世界のなんとか
ユーザー subsnsubsn
提出日時 2023-05-29 09:23:27
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,290 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 28,900 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-08-27 23:09:17
合計ジャッジ時間 1,363 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 AC 0 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <malloc.h>
char str[60000];//(5桁×10000件)+(空白1万-1) = 59999文字まで使われる可能性がある
int str_len = 0;

/// <summary>
/// グローバル変数strの中身を入力された文字列で上書きする
/// </summary>
void ReadString() {
	char c = getchar();
	str_len = 0;

	while (c != '\n') {
		str[str_len] = c;
		c = getchar();
		str_len++;
	}
}

/// <summary>
/// ReadStringの文字列のうち、スペースで区切られた左側か右側を取得する
/// </summary>
/// <param name="leftIs">左が欲しければtrue,右ならfalse</param>
/// <returns>引数に対応した側の数字を返す</returns>
int GetLR(int leftIs) {
	int cnt = 0;
	long num = 0;
	long left = 0;
	long right = 0;
	while (1) {
		if (cnt >= str_len) {
			right = num;
			break;
		}
		if (str[cnt] == ' ') {
			left = num;
			num = 0;
			cnt++;
			continue;
		}
		num = num * 10 + (str[cnt] - '0');
		cnt++;
	}
	if (leftIs) {
		return left;
	}
	else {
		return right;
	}
}

long main()
{
	ReadString();
	long a = GetLR(1);
	long b = GetLR(0);

	for (long long i = a;i <= b;i++) {
		if (i % 3 == 0) {
			printf("%lld\n",i);
			continue;
		}
		for (long long j = 1LL;j < i * 10;j*=10) {
			if ((i%(j*10))/j == 3) {
				printf("%lld\n",i);
			}
		}
	}
}
0