結果

問題 No.1336 Union on Blackboard
ユーザー snrnsidysnrnsidy
提出日時 2021-11-10 02:09:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 900 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 200,336 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-12 11:06:08
合計ジャッジ時間 4,184 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 3 ms
4,384 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
 
using namespace std;

const long long int MOD = 1e9 + 7;
long long int C[101][101];

long long int mypow(long long int x,long long int n)
{
	long long int res = 1;
	while(n > 0)
	{
		if(n%2==1)
		{
			res *= x;
			res%=MOD;
		}
		x*=x;
		x%=MOD;
		n/=2;
	}
	return res;
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

	C[0][0] = 1;
	for(int i=1;i<=100;i++)
	{
		C[i][0] = 1;
		C[i][i] = 1;
		for(int j=1;j<i;j++)
		{
			C[i][j] = C[i-1][j] + C[i-1][j-1];
			C[i][j]%=MOD;
		}
	}

	int tc;

	cin >> tc;

	while(tc--)
	{
		int n;
		long long int t;
		vector <long long int> v;
		cin >> n;
		for(int i=0;i<n;i++)
		{
			cin >> t;
			v.push_back(t);
		}

		long long int A = v[0];
		for(int i=1;i<n;i++)
		{
			long long int B = v[i];
			long long int C = (A+B)%MOD;
			C += ((A*B)%MOD);
			C%=MOD;
			A = C;
		}
		
		cout << A << '\n';

	}
    return 0;
}
0