結果

問題 No.2560 A_1 < A_2 < ... < A_N
ユーザー Ayush RawatAyush Rawat
提出日時 2023-12-07 20:15:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 170,552 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-07 20:15:05
合計ジャッジ時間 3,999 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 21 ms
6,676 KB
testcase_02 AC 23 ms
6,676 KB
testcase_03 AC 20 ms
6,676 KB
testcase_04 AC 23 ms
6,676 KB
testcase_05 AC 25 ms
6,676 KB
testcase_06 AC 140 ms
6,676 KB
testcase_07 AC 140 ms
6,676 KB
testcase_08 AC 166 ms
6,676 KB
testcase_09 AC 142 ms
6,676 KB
testcase_10 AC 142 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 4 ms
6,676 KB
testcase_14 AC 4 ms
6,676 KB
testcase_15 AC 3 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// C++ Program to find sum of Fibonacci numbers in 
// O(Log n) time.
#include <bits/stdc++.h>
using namespace std;
const long long MAX = LLONG_MAX;


// Driver program to test above function
int main()
{
	int t;
	cin>>t;
	while(t--){
		long long n,x;
		cin>>n>>x;
		if(n == 1){
			cout<<x<<"\n";
			continue;
		}
		vector<long long >ans;
		long long sum = 0;
		for(long long i=1; i<=x; i++){
			if(n == 1){
				if(x-sum>ans.back()){
					ans.push_back(x-sum);
					n--;
				}
				break;
			}
			sum+=i;
			ans.push_back(i);
			n--;
		}
		// cout<<ans.size()<<" " <<n<<endl;
		if(n){
			cout<<-1<<"\n";
			continue;
		}
		for(auto i: ans)
			cout<<i<<" ";
		cout<<"\n";
	}
}
0