B表示完全看不懂。。就不弄了。。

E字符串先不管了。到时候系统学下字符串再处理

A

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == ? b : gcd(b, a % b);}
int src[];
int main()
{
int K;
scanf("%d",&K);
for (int i = ; i < ; i++) scanf("%d",&src[i]);
sort(src,src+);
int ans = ,sum = , cas = ;
while (true)
{
if (sum >= K) break;
if (ans == ) break;
sum += src[cas];
cas--;
ans++;
}
if (ans == ) puts("-1");
else printf("%d\n",ans);
return ;
}

C

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == ? b : gcd(b, a % b);}
#define MAXN 100005
int N;
struct node
{
int id;
int val;
friend bool operator < (const node & a,const node &b)
{
return a.val < b.val;
}
}src[MAXN];
LL sum[MAXN];
node stl[MAXN],str[MAXN];
int main()
{
scanf("%d",&N);
sum[] = ;
for (int i = ; i <= N; i++)
{
scanf("%d",&src[i].val);
src[i].id = i ;
sum[i] = sum[i - ] + src[i].val;
}
sort(src + , src + + N);
int topl = ,topr = ;
if (N % == )
{
for (int i = ; i <= N; i++)
{
if (i % == ) stl[topl++] =src[i];
else str[topr++] = src[i];
}
printf("%d\n",N / );
for (int i = ; i < topl; i++) printf("%d ",stl[i].id);
putchar('\n');
printf("%d\n",N / );
for (int i = ; i < topr; i++) printf("%d ",str[i].id);
putchar('\n');
}
else
{
for (int i = ; i <= N; i += )
stl[topl++] =src[i];
for (int i = ; i <= N; i += )
str[topr++] = src[i];
printf("%d\n",N / + );
for (int i = ; i < topl; i++ ) printf("%d ",stl[i].id);
putchar('\n');
printf("%d\n", N / );
for (int i = ; i < topr; i++) printf("%d ",str[i].id);
putchar('\n');
}
return ;
}

D

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == ? b : gcd(b, a % b);}
#define MOD 1000000007
char input[];
struct node
{
char res;
int id;
}src[];
int G[];
node sta[];
LL dp[][][][];
void calcu(int l ,int r)
{
if (l >= r) return ;
if (l + == r)
{
dp[l][r][][] = ;
dp[l][r][][] = ;
dp[l][r][][] = ;
dp[l][r][][] = ;
}
if (G[l] == r)
{
calcu(l + ,r - );
for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
{
if (j != ) dp[l][r][][] = (dp[l][r][][] + dp[l + ][r - ][i][j]) % MOD;
if (j != ) dp[l][r][][] = (dp[l][r][][] + dp[l + ][r - ][i][j]) % MOD;
if (i != ) dp[l][r][][] = (dp[l][r][][] + dp[l + ][r - ][i][j]) % MOD;
if (i != ) dp[l][r][][] = (dp[l][r][][] + dp[l + ][r - ][i][j]) % MOD;
}
return ;
}
else
{
int t = G[l];
calcu(l,t);
calcu(t + , r);
for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
for (int m = ; m < ; m++)
for (int n = ; n < ; n++)
{
if (!( (m == && n == ) || (m == && n == )))
dp[l][r][i][j] = (dp[l][r][i][j] + (dp[l][t][i][m] * dp[t + ][r][n][j]) % MOD) % MOD;
}
}
}
int main()
{
while (scanf("%s",input + ) != EOF)
{
int len = strlen(input + );
int top = ;
for (int i = ; i <= len; i++)
{
if (input[i] == '(')
{
node tmp;
tmp.id = i;
tmp.res = input[i];
sta[top++] = tmp;
}
else
{
if (sta[top - ].res == '(')
{
G[i] = sta[top - ].id;
G[sta[top - ].id] = i;
top--;
}
else
{
node tmp;
tmp.id = i;
tmp.res = input[i];
sta[top++] = tmp;
}
}
}
memset(dp,,sizeof(dp));
calcu(,len);
LL ans = ;
for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
ans = (ans + dp[][len][i][j]) % MOD;
printf("%I64d\n",ans % MOD);
}
return ;
}

Codeforces 106 DIV2 ACD的更多相关文章

  1. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  2. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  3. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  4. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  5. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  6. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  7. Codeforces 106 C 多重背包

    题目链接:http://codeforces.com/problemset/problem/106/C 根据题意列出式子,设每种蛋糕做了xi个,则对于每种材料bi*xi<=ai. 对于dough ...

  8. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  9. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

随机推荐

  1. 数据库学习(三) sql语句中添加函数 to_char,round,连接符||

    ** to char 是把日期或数字转换为字符串  to date 是把字符串转换为数据库中得日期类型  参考资料:https://www.cnblogs.com/hllnj2008/p/533296 ...

  2. fiddler抓包-简单易操作(二)

    Fiddler抓包简介 原理:fiddler是通过改写HTTP代理,客户端和服务器进行交互时,数据会从他那里通过,来监控和截取数据.我是这样理解的,如果不对,欢迎指正.如下图: 如果想要抓到数据包,首 ...

  3. HDU 3696 Farm Game(拓扑+DP)(2010 Asia Fuzhou Regional Contest)

    Description “Farm Game” is one of the most popular games in online community. In the community each ...

  4. DFS(8)——poj2034Anti-prime Sequences

    一.题目回顾 题目链接:Anti-prime Sequences Sample Input 1 10 2 1 10 3 1 10 5 40 60 7 0 0 0   Sample Output 1,3 ...

  5. [比赛总结]ACM div3 G 比赛总结

    这次题目总体感觉和做阅读理解差不多,英文题目读起来相当费劲. 另外,这次比赛整个队伍中我们三个都突出存在的问题就是,把简单问题复杂化,抓不到事物的本质,因此很容易的就被题目误导. 比如C题,明明想到了 ...

  6. 创建带maven的javaWeb项目

    1File——Maven——maven-archtypes-webapp GroupId:表示项目组织唯一标识符 ArtifacrId:表示项目唯一标识符 例如项目名称 Version是项目版本 这三 ...

  7. 【Android入门】——模拟器的创建及常见问题汇总

    [前言] 刚刚接触Android,第一门课我们就来创建一个模拟器.安卓模拟器,简称AVD(Android Virtual Device),是安卓运行的虚拟设备.有了他以后,我们就不需要在连着安卓手机进 ...

  8. application/x-www-form-urlencoded从前端到后台

    html <form id="userForm1" enctype="application/x-www-form-urlencoded" method= ...

  9. Maven中如何将源码之外的文件打包及添加本地jar

    <build> <resources> <resource> <directory>src/main/resources</directory&g ...

  10. Delphi中动态创建窗体有四种方式

    Delphi中动态创建窗体有四种方式,最好的方式如下: 比如在第一个窗体中调用每二个,主为第一个,第二个设为动态创建 Uses Unit2; //引用单元文件 procedure TForm1.But ...