Submission #836642


Source Code Expand

Copy
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200000;

int n, c, a[N], b[N];

long long dp[1000][1000];
long long P[1000][1000];

long long pw(long long a, long long b)
{
	if (b == 0)
		return 1;
	if (b % 2)
		return a*pw(a, b - 1) % bs;
	return pw(a*a%bs, b / 2);
}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n >> c;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> b[i];
	}

	dp[0][0] = 1;

	for (int i = 1; i <= 400; i++)
	{
		for (int j = 0; j <= 400; j++)
		{
			if (j == 0)
				P[i][j] = 1;
			else
				P[i][j] = P[i][j - 1] * i%bs;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int ad = 0; ad <= c; ad++)
		{
			long long val = 0;
			for (int j = a[i + 1]; j <= b[i + 1]; j++)
			{
				val += P[j][ad];// pw(j, ad);
				val %= bs;
			}
			for (int sum = 0; sum <= c; sum++)
			{
				dp[i + 1][sum + ad] += dp[i][sum] * val%bs;
				dp[i + 1][sum + ad] %= bs;
			}
		}
	}

	cout << dp[n][c] << endl;

	cin.get(); cin.get();
	return 0;
}

Submission Info

Submission Time
Task E - Children and Candies
User LeBron
Language C++14 (GCC 5.4.1)
Score 800
Code Size 1926 Byte
Status AC
Exec Time 1047 ms
Memory 6272 KB

Compile Error

./Main.cpp:33:0: warning: "M_PI" redefined
 #define M_PI 3.141592653589793
 ^
In file included from /usr/include/c++/5/cmath:44:0,
                 from /usr/include/c++/5/complex:44,
                 from ./Main.cpp:10:
/usr/include/math.h:372:0: note: this is the location of the previous definition
 # define M_PI  3.14159265358979323846 /* pi */
 ^

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 400 / 400 400 / 400
Status
AC × 5
AC × 12
AC × 30
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt
Subtask 0_001, 0_003, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 2_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt
Case Name Status Exec Time Memory
0_000.txt AC 10 ms 3072 KB
0_001.txt AC 9 ms 3072 KB
0_002.txt AC 10 ms 3072 KB
0_003.txt AC 9 ms 3200 KB
0_004.txt AC 10 ms 3072 KB
1_005.txt AC 9 ms 3072 KB
1_006.txt AC 9 ms 3072 KB
1_007.txt AC 9 ms 3072 KB
1_008.txt AC 10 ms 3072 KB
1_009.txt AC 11 ms 3072 KB
1_010.txt AC 11 ms 3072 KB
1_011.txt AC 13 ms 4736 KB
1_012.txt AC 14 ms 4736 KB
1_013.txt AC 18 ms 4736 KB
1_014.txt AC 487 ms 6272 KB
1_015.txt AC 484 ms 6272 KB
1_016.txt AC 482 ms 6272 KB
2_017.txt AC 10 ms 3072 KB
2_018.txt AC 10 ms 3072 KB
2_019.txt AC 12 ms 3072 KB
2_020.txt AC 12 ms 3072 KB
2_021.txt AC 17 ms 4736 KB
2_022.txt AC 15 ms 4736 KB
2_023.txt AC 1047 ms 6272 KB
2_024.txt AC 675 ms 6272 KB
2_025.txt AC 159 ms 5632 KB
2_026.txt AC 21 ms 4480 KB
2_027.txt AC 542 ms 6016 KB
2_028.txt AC 29 ms 3712 KB
2_029.txt AC 15 ms 3328 KB