結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 1 ms
4,380 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 0 ms
4,380 KB
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);
				break;
			}
		}
	}
}
0