/*
ID: bbezxcy1
PROG: numtri
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,map[1002][1002];
int main(){
int n,i,j,a,b,c;
freopen("numtri.in","r",stdin );
freopen("numtri.out","w",stdout );
while(scanf("%d",&n)!=EOF){
for(i=1;i<=n;i++){
for(j=1;j<=i;j++){
scanf("%d",&map[i][j]);
}
}
for(i=n-1;i>=1;i--){
for(j=1;j<=i;j++){
map[i][j]+=max(map[i+1][j],map[i+1][j+1]);
}
}
printf("%d\n",map[1][1]);
}
return 0;
}
//第二题,只把打表代码写上吧
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
bool isPrim(int n){
int m=sqrt(n);
if(n==2)return 1;
for(int i=2;i <=m;i++){
if(n%i==0)
return false;
}
return true;
}
bool isback(int n){
char str[20];
int len=0;
while(n)
{
str[len++]=n%10;
n/=10;
}
for(int i=0;i<len;i++){
if(str[i]!=str[len-i-1]){
return 0;
}
}
return 1;
}
int main(){
int cnt=1;
freopen("namenum.out","w",stdout );
cout<<2<<" ";
for(int i=2;i<=100000000;i++){
if(i%2==0)continue;
if(isPrim(i)&&isback(i)){
cnt++;
printf("%d,",i);
}
}
cout<<"cnt="<<cnt<<endl;
return 0;
}
/*
ID: bbezxcy1
PROG: sprime
LANG: C++
*/
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
int len;
bool check(int d)
{
int i;
for (i=2;i<=(int)sqrt(d);i++)
if (d%i==0) return true;
return false;
}
int tail[5];//={1,3,7,9};
void dfs(int num,int dep)
{
if(dep==len)
{
printf("%d\n",num);
return;
}
int a,i;
for(i=0;i<4;i++)
{
a=num*10+tail[i];
if(check(a))
{
dfs(a,dep+1);
}
}
}
int main()
{
freopen("sprime.in","r",stdin );
freopen("sprime.out","w",stdout );
tail[0]=1;tail[1]=3;tail[2]=7;tail[3]=9;
while(scanf("%d",&len)!=EOF)
{
if(len==1){
printf("2\n3\n5\n7");
continue;
}
dfs(2,1);
dfs(3,1);
dfs(5,1);
dfs(7,1);
}
return 0;
}
/*
ID: bbezxcy1
PROG: checker
LANG: C++
*/
#include<fstream>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int aaa[50],bbb[50],ccc[50],n,res[50],tot;
ifstream fin("checker.in");
ofstream fout("checker.out");
void dfs(int dep) //dep代表当前的行
{
int i;
if(dep==n)
{
tot++;
if(tot<=3)
{
for(i=0;i<n-1;i++)
{
fout<<res[i]+1<<" ";
//printf("%d ",res[i]+1);
}//printf("%d\n",res[n-1]+1);
fout<<res[n-1]+1<<endl;
}
return;
}
for(i=0;i<n;i++)
{
if(!aaa[i]&&!bbb[dep-i+n]&&!ccc[i+dep])
{
aaa[i]=bbb[dep-i+n]=ccc[i+dep]=1;
res[dep]=i;
dfs(dep+1);
aaa[i]=bbb[dep-i+n]=ccc[i+dep]=0;
}
}
}
int main()
{
// freopen("checker.in","r",stdin );
// freopen("checker.out","w",stdout );
int i,j,a,b,c;
while(fin>>n)//scanf("%d",&n)!=EOF
{
tot=0;
memset(aaa,0,sizeof(aaa));
memset(bbb,0,sizeof(bbb));
memset(ccc,0,sizeof(ccc));
dfs(0);
fout<<tot<<endl;
//printf("%d\n",tot);
}
return 0;
}