結果

問題 No.793 うし数列 2
ユーザー Joy Yeh
提出日時 2019-02-25 15:51:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 650 bytes
コンパイル時間 809 ms
コンパイル使用メモリ 56,412 KB
実行使用メモリ 13,696 KB
最終ジャッジ日時 2024-12-26 05:00:54
合計ジャッジ時間 40,540 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 TLE * 13
権限があれば一括ダウンロードができます

ソースコード

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