SRM 595 DIV1 250

挺简单的组合把。

 1 #include <cstdio>

 2 #include <cstring>

 3 #include <iostream>

 4 #include <vector>

 5 using namespace std;

 6 #define LL long long

 7 int flag[1001];

 8 int p[1001];

 9 class LittleElephantAndIntervalsDiv1

10 {

11 public :

12     LL getNumber(int M, vector <int> L, vector <int> R)

13     {

14         LL ans = 1;

15         int i,j;

16         for(i = 0;i < L.size();i ++)

17         {

18             for(j = L[i];j <= R[i];j ++)

19             p[j] = i+1;

20         }

21         for(i = 1;i <= M;i ++)

22         {

23             if(p[i]&&!flag[p[i]])

24             {

25                 flag[p[i]] = 1;

26                 ans *= 2;

27             }

28         }

29         return ans;

30     }

31 };

 

你可能感兴趣的:(div)