結果

問題 No.294 SuperFizzBuzz
ユーザー IL_mstaIL_msta
提出日時 2015-10-23 23:53:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,609 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 88,296 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-11 04:46:16
合計ジャッジ時間 1,683 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,356 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 30 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:89:37: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   cal =  base.substr(baseLen-(i+1),i+1);
                                    ~^~

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
/////////

void solve(){
	int N;
	cin >> N;
	//5533533555333355355553555(25桁)
	string base = "3333333333333333333333535";
	int baseLen = base.size();
	int num = 0;
	string cal;
	int calLen;
	int A,B;
	int i,j;
	bool flag;
	if( N <= 1000000 ){
		num = 0;
		base = "3333333333333333333333535";
		i = 2;
	}else if( N <= 2000000 ){
		num = 1000000;
		base = "3333553555333553553333555";
		i = 21;
	}else if( N <= 3000000 ){
		num = 2000000;
		base = "3335535553335535355553555";
		i = 22;
	}else if( N <= 4000000 ){
		num = 3000000;
		base  = "333533535353533353335355";
		i = 23;
	}else if( N <= 5000000 ){
		num = 4000000;
		base  = "355355533355353555553355";
		i = 23;
	}else if( N <= 6000000 ){
		num = 5000000;
		base  = "553353355533335535533535";
		i = 23;
	}else if( N <= 7000000 ){
		num = 6000000;
		base = "3335335353535333533335535";
		i = 24;
	}else if( N <= 8000000 ){
		num = 7000000;
		base = "3533333335535555335555335";
		i = 24;
	}else if( N <= 9000000 ){
		num = 8000000;
		base = "3553555333553553333333555";
		i = 24;
	}else if( N <= 10000000 ){
		num = 9000000;
		base = "5335535555555533535555355";
	}else{
		cout << "5533533555333355355553555\n";
		return;
	}
	for(i;i<baseLen;++i){
		cal =  base.substr(baseLen-(i+1),i+1);
		calLen = i+1;
		for(;;){
			flag = false;
			if( cal[calLen-2] == '5' ){
				flag = true;
				cal[calLen-2] = '3';
			}else{
				cal[calLen-2] = '5';
			}
			for(j=calLen-3;j>=0;--j){
				if( flag ){
					if( cal[j] == '5' ){
						cal[j] = '3';
					}else{
						cal[j] = '5';
						flag = false;
					}
				}else{
					break;
				}
			}
			if( flag ){
				break;
			}
			////////////////
			//cout << cal << endl;
			if( cal[calLen-1] != '5')continue;
			A = 0;
			B = 0;
			for(j=0;j<calLen;++j){
				if( cal[j] == '3' ){
					++A;
				}else{
					++B;
				}
			}
			if(B%3 != 0 )continue;
			++num;
			if( N == num ){
				cout << cal << endl;
				return;
			}

			
		}
	}
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	//cpp
	solve();
	return 0;
}
0