結果

問題 No.689 E869120 and Constructing Array 3
ユーザー kotatsugamekotatsugame
提出日時 2020-02-23 05:26:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 374 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 65,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 08:21:32
合計ジャッジ時間 2,011 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
using namespace std;
int K;
main()
{
	cin>>K;
	for(int i=0;i*(i-1)/2<=K;i++)
	{
		int t=K-i*(i-1)/2;
		int s=1;
		for(int j=1;j*j<=t;j++)
		{
			if(t%j==0)s=j;
		}
		if(i+s+t/s<=250)
		{
			cout<<i+s+t/s<<endl;
			for(int j=0;j<i;j++)cout<<"1 ";
			for(int j=0;j<s;j++)cout<<"3 ";
			for(int j=0;j<t/s;j++)cout<<"8 ";
			cout<<endl;
			return 0;
		}
	}
}
0