1376

Timewilltell_5

Paly_boy
77777777777
ephemeral.

Altair_yyds
a阿哲啊
chen-zhe-aya
Sky390

s.y.
4ppleS
zwling

//这里填你的代码^^
#include <iostream>

using namespace std;

const int N = 1010;
int n;
int s[N];
int f[N][N];

int main(){
cin >> n;

for(int i = 1;i <= n;i ++)cin >> s[i];

for(int i = 1;i <= n;i ++)s[i] = s[i] + s[i - 1];

for(int len = 2;len <= n;len ++){
for(int i = 1;i + len - 1 <= n;i ++){
int l = i,r = i + len -1;
f[l][r] = 1e8;
for(int k = l;k <= r;k ++){
f[l][r] = min(f[l][r],f[l][k] + f[k + 1][r] + s[r] - s[l - 1]);
}
}
}

cout << f[1][n] << endl;

return 0;
}
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


//这里填你的代码^^
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1010;
int n,m;
char a[N],b[N];
int f[N][N];

int main(){
cin >> n >> m;

scanf("%s%s",a + 1,b + 1);

for(int i = 1;i <= n;i ++){
for(int j = 1;j <= m;j ++){
f[i][j] = max(f[i - 1][j],f[i][j - 1]);
if(a[i] == b[j])f[i][j] = max(f[i][j],f[i - 1][j - 1] + 1);
}
}

cout << f[n][m] << endl;
return 0;
}
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


//这里填你的代码^^
#include <iostream>
#include <unordered_map>

using namespace std;

int n,m,cnt;
string str,s,c;

string maxn(string a,string b){
int A = 0,B = 0;
for(int i = 6;i <= 13;i ++){
A = 10 * A + a[i] - '0';
B = 10 * B + b[i] - '0';
}
if(A > B)return b;
else return a;
}
int main(){
cin >> n;

unordered_map<string,bool> hash;

while(n --){
cin >> str;
hash[str] = true;
}

cin >> m;

while(m --){
cin >> str;
if(hash[str]){
cnt ++;
if(s.size())s = maxn(s,str);
else s = str;
}
else{
if(c.size())c = maxn(str,c);
else c = str;
}
}
cout << cnt << endl;
if(cnt){
cout << s << endl;
}
else cout << c << endl;
return 0;
}
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


#### C++ 代码

#include <iostream>

using namespace std;

int n;

bool is_prime(int x){
if(x <= 1)return false;
for(int i = 2;i <= x / i;i ++){
if(x % i == 0)return false;
}
return true;
}

int main(){
cin >> n;

if(is_prime(n) && (is_prime(n - 6) || is_prime(n + 6)) ){
cout << "Yes" << endl;
if(is_prime(n - 6))cout << n - 6 << endl;
else cout << n + 6  << endl;
}
else{
cout << "No" << endl;
for(int i = n + 1;;i ++){
if(is_prime(i) &&(is_prime(i - 6) || is_prime(i + 6))){
cout << i << endl;
break;
}
}
}
return 0;
}


//这里填你的代码^^
#include <iostream>

using namespace std;

int n;

bool is_prime(int x){
if(x <= 1)return false;
for(int i = 2;i <= x / i;i ++){
if(x % i == 0)return false;
}
return true;
}

int main(){
cin >> n;

if(is_prime(n) && (is_prime(n - 6) || is_prime(n + 6)) ){
cout << "Yes" << endl;
if(is_prime(n - 6))cout << n - 6 << endl;
else cout << n + 6  << endl;
}
else{
cout << "No" << endl;
for(int i = n + 1;;i ++){
if(is_prime(i) &&(is_prime(i - 6) || is_prime(i + 6))){
cout << i << endl;
break;
}
}
}
return 0;
}
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


#### C++ 代码

#include <iostream>

using namespace std;

int n;

void dfs(int u ,int state){
if(u == n){
for(int i = 0;i < n;i ++){
if(state >> i & 1)cout <<i + 1 << " " ;
}
cout << endl;
return ;
}
dfs(u + 1,state);
dfs(u + 1,state | 1 << u);
}

int main(){
cin >> n;

dfs(0,0);//当前已经选的数，状态
return 0;
}


#### C++ 代码

#include <iostream>

using namespace std;

const int N =1010;
int n,m;
int a[N];

void dfs(int u,int st){
if(u == m){
for(int i = 0;i < m;i ++) printf("%d ",a[i]);
cout << endl;
return ;
}
for(int i = st;i <= n;i ++){
a[u] = i;
dfs(u + 1,i + 1);
}
}
int main(){
cin >> n >> m;

dfs(0,1);//已经选的数，当前的位置

return 0;
}


#### C++ 代码

#include <iostream>

using namespace std;

int n;
const int N = 1010;
int a[N],f[N];

int main(){
cin >>n;

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

for(int i = 1;i <= n;i ++){
f[i] = 1;
for(int j = 1;j < i;j ++){//单调的，后面一个数大于前面一个数
if(a[i] > a[j])f[i] = max(f[i],f[j] + 1);// 前一个小于自己的数结尾的最大上升子序列加上自己，即+1
}
}

int res = 0;

for(int i = 1;i <= n;i ++)res = max(res,f[i]);

cout << res << endl;

return 0;
}


//这里填你的代码^^
#include <iostream>

using namespace std;

int n;
const int N = 1010;
int a[N],f[N];

int main(){
cin >>n;

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

for(int i = 1;i <= n;i ++){
f[i] = 1;
for(int j = 1;j < i;j ++){
if(a[i] > a[j])f[i] = max(f[i],f[j] + 1);
}
}

int res = 0;

for(int i = 1;i <= n;i ++)res = max(res,f[i]);

cout << res << endl;

return 0;
}
//注意代码要放在两组三个点之间，才可以正确显示代码高亮哦~


#### C++ 代码

#include <iostream>

using namespace std;

int n;
const int N = 510,INF = 1e9;
int a[N][N];
int f[N][N];

int main(){
scanf("%d",&n);

for(int i = 1;i <= n;i ++){
for(int j = 1;j <= i;j ++){
scanf("%d",&a[i][j]);
}
}

for(int i = 0;i <= n;i ++){//赋值
for(int j = 0;j <= i + 1;j ++){
f[i][j] = -INF;
}
}

f[1][1] = a[1][1];//边界

for(int i = 2;i <= n;i ++){
for(int j = 1;j <= i;j ++){
f[i][j] = max(f[i - 1][j - 1] + a[i][j],f[i - 1][j] + a[i][j]);
}
}

int res = -INF;

for(int i = 1;i <= n;i ++)res = max(res,f[n][i]);//n走到最底层的数之和

printf("%d\n",res);
return 0;
}