## 树根

#include <stdio.h>
int main()
{
unsigned long a=0,b=0;
int flag=2;
char c;
while(1)
{
a=0;b=0;flag=2;
c=getchar();
if(c=='0') break;
else
{     a=a+(c-'0');
while((c=getchar())!='\n')
{
if(((c-'0')!=9)&&((c-'0')!=0))
{
a=a+(c-'0');
}
}
// c='0';
while(flag>1)
{    if(a>9)
{
while(a!=0)
{    b=b+a%10;
a=a/10;
}
if(b>9)
{
flag=2;
a=b;
b=0;
}
else{
flag=0;
a=b;
b=0;
break;
}
}
else
{
break;
}
}
printf("%d\n",a);
}
}
}


public int addDigits(int num) {
return (num - 1) % 9 + 1;
}


## 回文串

#include <cstring>
#include<iostream>
using namespace std;
int isPalindrome(char str[])
{
int len=strlen(str);
int i,j;
i=0;
j=len-1;
while(i<j)
{
if(str[i++]!=str[j--]) return 0;
}
return 1;
}
int main(){
char str[10001];
int n,i=0;
cin>>n;
while(i<=n-1)
{   i=i+1;
cin>>str;
int a=0;
a=isPalindrome(str);
if(a==1) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}



## 其他

#include <stdio.h>
//#include <stdlib.h>
#define MAX 130
int maxSum(int b[], int n)
{
int max = b[0];
int sum = 0;
for(int i = 0; i < n; ++i)
{
if(sum < 0) sum = b[i];
else sum += b[i];
if(sum > max) max = sum;
}
return max;
}

int solve(int a[][MAX], int n)
{
int b[MAX];int i,j,k,sum,tmp;
sum = a[0][0];
for(i = 0; i < n; ++i)
{
for(k = 0; k < n; ++k) b[k] = 0;
for(j = i; j < n; ++j)
{
for(k =0; k < n; ++k) b[k] += a[j][k];
if(sum < (tmp = maxSum(b,n)) ) sum = tmp;
}
}
return sum;
}

int main()
{
int arr[MAX][MAX];
int i,j,n;
while(scanf("%d",&n)!=EOF)
{
for(i = 0; i < n; ++i)
for(j = 0; j < n; ++j)
scanf("%d",&arr[i][j]);
printf("%d",solve(arr,n));
break;
}
//  system("pause");
return 0;
}