結果

問題 No.793 うし数列 2
ユーザー Joy YehJoy Yeh
提出日時 2019-02-25 15:51:29
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 650 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 53,464 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-27 00:45:07
合計ジャッジ時間 4,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

bool dec_str(string &N) {
	// Format check should be done.
	bool const positive = (N != "0");

	// Decrement
	if (positive) {
		size_t const last_pos = N.size() - 1;
		if (N[last_pos] == '0') {
			size_t i = last_pos;
			while (N[i] == '0') {
				N[i--] = '9';
			}
			N[i]--;
		}
		else {
			N[last_pos]--;
		}

		while (N.size() > 1 and N[0] == '0') {
			N = N.substr(1);
		}
	}

	return positive;
}

#define DIVISOR 1000000007;
int main(void) {
	string N_3;
	cin >> N_3;
	long long num = 1;
	while (dec_str(N_3)) {
		num = (10 * num + 3) % DIVISOR;
	}
	cout << num << endl;
	return 0;
}
0