結果

問題 No.362 門松ナンバー
ユーザー koyumeishikoyumeishi
提出日時 2016-03-16 02:09:27
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 751 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 62,800 KB
実行使用メモリ 10,016 KB
最終ジャッジ日時 2024-04-09 19:57:06
合計ジャッジ時間 5,780 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <set>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

bool is_kadomatsu_digit(long long x){
	bool ok = true;
	stringstream ss;
	ss << x;
	string s;
	ss >> s;
	if(s.size()<=2) return false;
	int a = s[0] - '0';
	int b = s[1] - '0';

	for(int i=2; i<s.size(); i++){
		int c = s[i] - '0';
		if( (!(a>b && b<c && a!=c)) && (!(a<b && b>c && a!=c)) ) return false;
		a = b;
		b = c;
	}
	return true;
}

int main_(){
	int n; cin >> n;
	for(int i=100; n; i++){
		if(is_kadomatsu_digit(i)){
			n--;//s.insert(i);
		}
		if(n==0) cout << i << endl;
	}
	return 0;
}

#include <ctime>
int main(){
	//auto s = clock();
	int t;
	cin >> t;
	while(t--){
		main_();
	}
	//cerr << clock()-s << endl;
	return 0;
}
0