結果

問題 No.294 SuperFizzBuzz
ユーザー kotatsugamekotatsugame
提出日時 2020-02-17 06:56:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 501 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 67,052 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 03:43:39
合計ジャッジ時間 1,741 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 70 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 46 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 58 ms
5,376 KB
testcase_12 AC 65 ms
5,376 KB
testcase_13 AC 66 ms
5,376 KB
testcase_14 AC 72 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
int comb(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=ret*(a-i+1)/i;
	}
	return ret;
}
main()
{
	cin>>N;N--;
	int k=1;
	for(;;k++)
	{
		int now=0;
		for(int i=1;i*3<=k;i++)
		{
			now+=comb(k-1,i*3-1);
		}
		if(N<now)break;
		N-=now;
	}
	int i=7;
	for(;;i+=2)
	{
		if(__builtin_popcount(i)%3==0)
		{
			if(!N--)break;
		}
	}
	string ans="";
	for(int j=0;j<k;j++)
	{
		if(i%2)ans="5"+ans;
		else ans="3"+ans;
		i>>=1;
	}
	cout<<ans<<endl;
}
0