Pages

Monday, December 19, 2011

Failed d475: 玩具求幂题(求幂系列题2)

a224. 明明愛明明

Failed d563: 等值首尾和

d264. 极值问题

d392. 读取练习——强大的加法!

Failed d287. 古怪的数学家

d587. 參貳壹真好吃

d478: 共同的數 - 簡易版

a022. 迴文

d929. A. 迴文

failed d562: 山寨版磁力蜈蚣

Monday, August 15, 2011

d018. 字串讀取練習


#include
#include
#include
using namespace std;

const int SIZE = 3000;

int main()
{
char input[SIZE];
while(cin.getline(input,SIZE))
{
double sum=0;
char* pch;
pch = strtok(input," :");
while(pch !=NULL)
{
bool IsOdd;
if((int)atoi(pch)%2==1)
IsOdd=1;
else IsOdd=0;

pch = strtok(NULL," :");

if(IsOdd)
sum += atof(pch);
else
sum -= atof(pch);

pch = strtok(NULL," :");
}

cout< }
return 0;
}

Sunday, August 14, 2011

d098: Stringstream運用練習(C++)


#include
#include
#include
using namespace std;

bool IsAllInt(string str);


int main()
{
string input;

while(getline(cin,input))
{
int sum=0;
stringstream stream(input);

while(stream)
{
string word;
stream>>word;
if(IsAllInt(word))
{
sum += atoi(word.c_str());
}
}
cout< }
return 0;
}

bool IsAllInt(string str)
{
for(int i=0;i {
if(!isdigit(str[i]))
return 0;
}
return 1;
}

d583. 幼稚的企鵝


#include

using namespace std;

int main()
{
int n;

while(cin >> n)
{
for(int i=1; i<=n; i++)
{
int temp;
cin >> temp;
cout << i << " ";
}
cout << endl;
}
}

Saturday, August 13, 2011

d635. 幸運777?luck


#include
using namespace std;
int main() {
int input;
while(cin>>input)
{
if(input<0)
{
cout<<"-1"< break;
}
cout< }

return 0;
}

d649. 數字三角形


#include
#include
#include //格式控制
#include
using namespace std;
int main() {
int input;
while(cin>>input)
{
string str;
for(int i=1;i<=input;i++)
{
str +='+';
cout.setf(ios::right);
cout << setw(input) << setfill('_') << str< }
cout< }

return 0;
}

d059. 數學函數練習


#include
#include
#include //格式控制
using namespace std;
int main() {
double a,b;
cin>>a>>b;
cout << pow(a,b) << endl ; //a 的 b 次方

double c;
cin>>c;
cout << fixed << setprecision(3) << sqrt(c) << endl ;

int d;
cin>>d;
cout<
int e,f;
cin>>e>>f;
cout<<(rand()%(f-e))+e << endl ;

return 0;
}

d532. 文文的求婚 (三)


#include
using namespace std;

int main()
{
int a,b,count=0;
cin>>a>>b;
for(int year=a;year<=b;year++)
{
if((year%4==0 && year%100!=0) || (year%400==0))
count++;
}
cout<
return 0;
}

d559. 班號


#include
using namespace std;

int main()
{
int input;
while(cin>>input)
{
cout<<"'C' can use printf(\"%d\",n); to show integer like "< }

return 0;
}

d827. 買鉛筆


#include
using namespace std;

int main()
{
int input,dozens,singles,output;
cin>>input;

dozens = input/12;
singles = input%12;

output = dozens*50+singles*5;
cout< return 0;
}

d122. Oh! My Zero!!


#include
using namespace std;

int main()
{
long input;

while(cin>>input)
{
long output = 0;
while(input>4)
{
input/=5;
output +=input;
}
cout< }
return 0;
}

d489. 伏林的三角地


#include
//海龍公式
using namespace std;

int main()
{

int a,b,c;
cin >> a >> b >> c;

long long int ans = (long long int)(a+b+c)*(b+c-a)*(a+c-b)*(a+b-c);

cout << ans/16 << endl;
return 0;
}

Friday, August 12, 2011

d277. 矩形对角线


#include
using namespace std;

int main()
{
int n;
while(cin >> n)
{
if(n%2==0)
cout << n << endl;
else
cout << n-1 << endl;
}
}

d461. 班際籃球賽


#include
using namespace std;

int main()
{
int a;
cin>>a;
cout<<(a-1);

return 0;
}

d124. 3的倍数


#include
#include
using namespace std;

int main()
{
string str="0";
int input;

while(getline(cin,str))
{
int sum=0;
for(int i=0;i {
sum += str[i];
sum = sum%3;
}
if(sum==0)
cout<<"yes"< else
cout<<"no"<
}

return 0;
}

Thursday, August 11, 2011

d086. 態度之重要的證明


#include
using namespace std;
#include

int main()
{

string str;
while(cin>>str)
{
int size=0,points=0,allchar=1;
size=str.size();
if(size==1 && str[0]=='0')
{
break;
}
for(int i=0;i {
if(!isalpha(str[i]))
{
allchar=0;
break;
}
char a;
a=str[i];
a=tolower(a);
points += a-'a'+1;
}
if(allchar)
cout< else
cout<<"Fail"< str.clear();

}



return 0;
}

Wednesday, August 10, 2011

d460. 山六九之旅


#include
using namespace std;

int main (){
int n ;
while(cin >> n)
{
cout << (n>=0)*0+(n>=6)*590+(n>=12)*200+(n>=18)*100-(n>=60)*491<< endl ;
}
}

a104. 排序


#include
using namespace std;
#include

int main()
{
int size;
while(cin>>size)
{
int arr[100000];
for(int i=0;i {
cin>>arr[i];
}
sort(arr,arr+size);

for(int i=0;i {
cout< }
cout< }

return 0;
}

d507. 三角形的判斷


#include
using namespace std;

int main()
{
int a,b,c;
while(cin>>a>>b>>c)
{
int sides[3]={a,b,c};
sort(sides,sides+3);
a=sides[0];
b=sides[1];
c=sides[2];
if( c*c > (a*a+b*b) )
cout<<"obtuse triangle";
else if(c*c < (a*a+b*b) )
cout<<"acute triangle";
else cout<<"right triangle";

}
system("pause");
return 0;
}

d511. 小明的作業


#include

using namespace std;

int main()
{
int a,b,c;
int point=0;
while(cin>>a>>b>>c)
{
int max=0,other_two=0;
max = (a>b)? a:b;
max = (max>c)? max:c;
other_two = a+b+c-max;

if(other_two>max)
point++;
}
cout<
//system("pause");
return 0;
}

Monday, August 8, 2011

d491. 我也愛偶數 (swap 版)


#include
using namespace std;
#include


int main()
{
int a,b;
while(cin>>a>>b)
{
if(a>b)
{
int temp=a;
a=b;
b=temp;
}
int sum=0;
for(int i=a;i<=b;i++)
{
if(i%2==0) //別種寫法?
sum += i;
}
cout< }

return 0;
}

d490. 我也愛偶數 d485 我愛偶數


#include
using namespace std;
#include


int main()
{
int a,b;
while(cin>>a>>b)
{
int sum=0;
for(int i=a;i<=b;i++)
{
if(i%2==0) //別種寫法?
sum += i;
}
cout< }

return 0;
}

a040. 阿姆斯壯數


#include
using namespace std;
#include
#include

bool IsArm(int thenum);

int main()
{
int a,b;
while(cin>>a>>b)
{
int flag_hasArm=0;
for(int num=a;num<=b;num++)
{
if(IsArm(num))
{
cout< flag_hasArm=1;
}
}
if(!flag_hasArm)
cout<<"none";
cout< }


return 0;
}


bool IsArm(int thenum)
{

int a[100]={0},sum=0,size=0,temp=thenum;
for(int i=0;temp!=0;i++)
{
a[i] = temp % 10;
temp /= 10;
size++;
}

for(int j=0;j {
sum += pow((float)a[j],size);
}

return ((sum==thenum)? 1:0);
}


/*
bool IsArm(int thenum)
{
char buffer[100];
//string str="0";
itoa(thenum,buffer,10);
string str(buffer);
int sum=0,length=str.length();
for(int i=0;i {
sum += pow( (float)(str[i]-'0'),length);
}

return ((sum==thenum)? 1:0);
}
*/

Sunday, August 7, 2011

a034. 二進位制轉換


#include
using namespace std;
#include

int main()
{
string output;
int input;
while(cin>>input)
{
if (input==0)
cout<<"0";
while(input>0)
{
if(input%2==1)
output +="1";
else
output +="0";
input/=2;
}

for(int i=output.length()-1;i>=0;i--)
{
cout< }
cout< output.clear();
}

return 0;
}

a054. 電話客服中心


#include
using namespace std;

#include

bool CheckIsReal(int thesum,int thei);

int main()
{

string ID;


while (cin>>ID)
{
int sum=0;

for(int index=0,mul=8;mul>=1;index++,mul--)
{
sum += ( (ID[index]-(int)'0') * mul );
}
sum += (ID[8]-'0'); //最後一位數 千萬要注意'8'跟數字8是不同的!!

for(int i=0;i<=25;i++)
{
if (CheckIsReal(sum,i))
cout<<(char)(i+'A');
}
cout< }


return 0;
}

bool CheckIsReal(int thesum,int thei)
{
int v[]=
{ 10, 11, 12, 13, 14, 15, 16, 17, 34, 18, 19, 20, 21,
22, 35, 23, 24, 25, 26, 27, 28, 29, 32, 30, 31, 33};
int temp=0;
thesum += v[thei] / 10 ;
thesum += (v[thei]%10)*9;
if (thesum%10==0)
return 1;
else
return 0;
}

a020. 身分證檢驗



/*學習事項
1.使用string時,千萬注意數字與符號的數字是不同的 eg. '0' != 0
2.用cout除錯其實很好用
*/
#include
using namespace std;

#include

int AlphabetToInt(char letter);

int main()
{

string ID;

while (cin>>ID)
{
int sum=0, ch_num=0;
//deal with alphabet
sum += ( AlphabetToInt(ID[0]) / 10 );
sum += ( AlphabetToInt(ID[0]) % 10 )*9;
//cout<<( AlphabetToInt(ID[0]) / 10 )< //cout<<( AlphabetToInt(ID[0]) % 10 )*9< //cout << (int)'1'<
for(int index=1,mul=8;mul>=1;index++,mul--)
{
sum += ( (ID[index]-(int)'0') * mul );
//cout<< ID[index] << " " << (ID[index]-(int)'0') << " " < //cout< }
//cout< sum += (ID[9]-'0'); //最後一位數 千萬要注意'8'跟數字8是不同的!!
//cout< //cout< cout<<( (sum%10==0)? "real":"fake" )< }

//system("pause");
return 0;
}

int AlphabetToInt (char letter)
{
int v[]=
{ 10, 11, 12, 13, 14, 15, 16, 17, 34, 18, 19, 20, 21,
22, 35, 23, 24, 25, 26, 27, 28, 29, 32, 30, 31, 33};
int i = letter - 'A';
return v[i];
}

Tuesday, August 2, 2011

a058. MOD3


#include
using namespace std;

int main()
{
int many,num;
int remainder0=0,remainder1=0,remainder2=0;

cin>>many;
for(int i=0;i {
int remainder=0;
cin>>num;
remainder = num % 3;

switch ( remainder )
{
case 0 :
remainder0++;
break;
case 1 :
remainder1++;
break;
case 2 :
remainder2++;
break;
default :
break;
}
}
cout< return 0;

}

Monday, August 1, 2011

a065. 提款卡密碼


#include
using namespace std;
#include

int main()
{
string word;
while(cin>>word)
{
for(int i=0;i<6;i++)
{
int num;
num=abs( (int)word[i]-(int)word[i+1] ) ;
cout< }
cout< }


system("pause");
return 0;

}

Saturday, July 30, 2011

a059. 完全平方和


#include
#include
using namespace std;

int main()
{
int n;
cin>>n;
for(int group=0;group {
cout<<"Case "< int a,b,sum=0;
cin>>a>>b;
for(int num=a;num<=b;num++)
{
if( (sqrt(num)*sqrt(num)) == num)
sum += num;
}
cout< }

return 0;
}

a148. You Cannot Pass?!


#include

using namespace std;

int main()
{
int num;
while(cin>>num)
{
double sum=0,avg;
for(int i=0;i {
int score;
cin>>score;
sum += score;
}
avg = sum / num;
cout<<((avg>59)? "no":"yes")< }
return 0;
}

d072: 文文的求婚--續集 (Case 版)


#include

using namespace std;

int main()
{
int num;
cin>>num;
for(int i=0;i {
cout<<"Case "< int year;
cin>>year;
if((year%4==0 && year%100!=0) || year%400==0)
cout<<"a leap year"< else cout<<"a normal year"< }
return 0;
}

d071. 文文的求婚--續集 (EOF 版)


#include

using namespace std;

int main()
{
int year;
while(cin>>year)
{
if(cin.eof()) break;
if((year%4==0 && year%100!=0) || year%400==0)
cout<<"a leap year"< else cout<<"a normal year"< }
return 0;
}

d070. 文文的求婚--續集 (0 尾版)


#include

using namespace std;

int main()
{
int year;
while(cin>>year)
{
if(!year) break;
if((year%4==0 && year%100!=0) || year%400==0)
cout<<"a leap year"< else cout<<"a normal year"< }
return 0;
}

d074. 電腦教室


#include
using namespace std;

int main() {
int num,max=0;
cin>>num;
for(int i=0;i {
int people;
cin>>people;
if(people>max) max=people;
}
cout< return 0;
}

d073. 分組報告


#include
using namespace std;

int main() {
int num,ans;
cin>>num;
ans = ((num-1)/3+1);
cout< return 0;
}

d068. 該減肥了!


#include
using namespace std;

int main() {
int weight;
cin>>weight;
cout<< ((weight>50)? weight-1:weight);
return 0;
}

d069: 文文的求婚--續集 (n 行版)


#include
using namespace std;

int main() {
int num,y;
cin>>num;
for(int i=0;i {
cin>>y;
if( (y%4==0 && y%100!=0 )|| y%400==0)
cout<<"a leap year"< else cout<<"a normal year"< }
return 0;
}

d067. 文文的求婚--續集 (1 行版)


#include
using namespace std;

int main() {
int y;
cin>>y;
if( (y%4==0 && y%100!=0 )|| y%400==0)
cout<<"a leap year";
else cout<<"a normal year";
return 0;
}

a038. 數字翻轉


#include
using namespace std;

int main() {
string num;
while(cin>>num)
{
int l = num.length();
for(int i=0,flag_meet_value=0;i {
if(flag_meet_value==0 && num[l-1-i]=='0') continue;
else flag_meet_value=1;
if(flag_meet_value==1) cout< }
cout< }
return 0;
}

Friday, July 29, 2011

a044. 空間切割


#include
using namespace std;

int cut(int n)
{
if(n==1) return 2;
else return cut(n-1)+((n*n-n+2)/2);
}

int main(void)
{
int n;
while(cin>>n){
cout << cut(n) << endl ;
}
return 0;
}

a053. Sagit's 計分程式


#include

using namespace std;

int main()
{
int num;
while(cin>>num)
{
if(num<=10) cout< else if(num<=20) cout<<(num-10)*2+60< else if(num<=40) cout<<(num-20)*1+80< else cout<<100< }
return 0;
}

a149. 乘乘樂


#include

using namespace std;

int main()
{
int num;
cin>>num;
for(int i=0;i {
int integer;
int mul,mul_sum=1;
cin>>integer;
while(integer%10!=0)
{
mul = integer%10;
mul_sum *= mul;
integer /= 10;
}
cout<
}
return 0;
}

a042. 平面圓形切割


#include
using namespace std;

int main(){
int n;
while (cin >> n)
{
cout << n*n-n+2 << endl;
}
return 0;
}

a121. 質數又來囉


#include
using namespace std;
#include

int main()
{
int a,b;
while(cin>>a>>b)
{
int prime_num=0;
for(int num=a;num<=b;num++)
{
if (num==1) continue;
else if(num==2){ prime_num++;continue;}
else if(num==3) { prime_num++;continue;}
else
{
int flag_isprime=1;
for(int factor=2;factor<=sqrt(num)+1;factor++)
if(num%factor==0){flag_isprime=0;break;}
if (flag_isprime==1)
prime_num++;
}
}
cout< }
return 0;
}

a147: Print it all


#include
using namespace std;

int main()
{
int num;
while(cin>>num)
{
for(int i=1;i {
if(i%7==0) continue;
cout< }
cout< }
return 0;
}

d498 我不說髒話


#include
using namespace std;

int main()
{
int times;
cin>>times;
for(int i=0;i cout<<"I don't say swear words!"< return 0;
}

d485: 我愛偶數


#include
using namespace std;

int main()
{
int a,b,evens_num;
cin>>a>>b;
evens_num = abs(a-b)/2;
if(a%2==0 || b%2==0)
evens_num++;
cout< return 0;
}

d050. 妳那裡現在幾點了?


#include
using namespace std;

int main()
{
int tw_time,us_time;
cin >> tw_time;
us_time = (tw_time + 24 -15 )%24;
cout << us_time << endl;
return 0;
}

d049: 中華民國萬歲!


#include
using namespace std;

int main()
{
int year;
cin >> year;
cout<< year - 1911 < return 0;
}

d058: BASIC 的 SGN 函數


#include
#include
using namespace std;

int main()
{
int t;
while(cin >> t)
{
cout<<( t > 0 ? 1 : (t < 0 ? -1 : 0) );
}
return 0;
}

d051 糟糕,我發燒了!


//參考網頁 http://www.wretch.cc/blog/mntkey/21031128

#include
#include
using namespace std;

int main()
{
double F;
double C;
cin >> F;
C = ( F - 32 ) * 5 / 9;
cout << fixed << setprecision(3) << C << endl;
return 0;
}

d010: 盈數、虧數和完全數


#include
using namespace std;
#include
#define ATSCHOOL_MINUTES 450 //60*7+30=450
#define OFFSCHOOL_MINUTES 1020 //60*17+0=1020

int main()
{
int num;
while(cin>>num)
{
int factors_sum=0;
for(int factor=1;factor {
if(num % factor == 0)
{
factors_sum += factor;
}
}
if(factors_sum cout<<"虧數"< else if(factors_sum>num)
cout<<"盈數"< else
cout<<"完全數"< }
return 0;
}

d060: 還要等多久啊?


#include
using namespace std;

int main() {
int m ;
while(cin >> m)
{
cout << (85-m) % 60 << endl ;
}
return 0;
}

d066 上學去吧!


#include
using namespace std;
#include
#define ATSCHOOL_MINUTES 450 //60*7+30=450
#define OFFSCHOOL_MINUTES 1020 //60*17+0=1020

int main()
{
int hour,minute,time,atschoolMinute,OFFSCHOOL;
cin>>hour>>minute;
time = hour*60 + minute;
cout<< ( (ATSCHOOL_MINUTES<=time && time
return 0;
}

d065 三人行必有我師


#include
#include

using namespace std;

int main(int argc, char *argv[])
{
int a,b,c,biggerNum;
while(cin>>a>>b>>c)
{
biggerNum = max(a,b);
biggerNum = max(biggerNum,c);
cout< }
return 0;
}

d064. ㄑㄧˊ 數?


#include

using namespace std;

int main(int argc, char *argv[])
{
int input;
while(cin>>input)
{
cout<< ((input%2==0)? "Even":"Odd")<

}
return EXIT_SUCCESS;
}

d063: 0 與 1


#include

using namespace std;

int main(int argc, char *argv[])
{
int input;
while(cin>>input)
{
cout< }

return EXIT_SUCCESS;
}

Wednesday, July 27, 2011

a011. 幼稚園的算數遊戲


/*
程式碼長度: 606 Bytes
執行檔大小: 10341 Bytes
*/

#include
using namespace std;
#include

int main()
{
string str1;
int n=0;
int firstch=1;
while(getline(cin,str1))
{
for(int i=0; i<=str1.length(); i++)
{
if(isalpha(str1[i])!=0)
{
if(firstch==1)
{
n++;
}
firstch=0;
}
else
{
firstch=1;
}
}
cout< n=0;
}

system("pause");
return 0;
}

a010. 因數分解


/*
程式碼長度: 1538 Bytes
執行檔大小: 9121 Bytes
*/

#include
using namespace std;
#include

int main()
{
int input;
int p_input;
int pow=0;
int firstdigit=1;
int dividable=0;
while(cin>>input)
{
p_input=input;
for(int i=2;i<= p_input;i++)
{
while(p_input%i==0)
{
dividable=1;
pow++;
p_input = p_input/i;
}

if(dividable==1)
{
if(firstdigit==0)
{
cout<<" * ";
}
else
{
firstdigit=0;
}


if(pow==1)
{
cout< }
else if(pow>1)
{
cout<< i<<"^"< }
dividable=0;
pow=0;

}
}
firstdigit=1;
cout< }


return 0;
}

Tuesday, July 26, 2011

a012: Hashmat的戰役


#include
using namespace std;

int main()
{
long long x, y;
while( cin >> x >> y )
cout << abs( x-y ) << endl;
return 0;
}

a008: 中文大寫數字


#include
using namespace std;
#include

int main( void )
{
string number[15] = { "零", "壹", "貳", "參", "肆", "伍", "陸", "柒", "捌", "玖" };
string value[15] = { "", "拾", "佰", "仟", "萬", "拾", "佰", "仟", "億", "拾", "佰"};

int num;
while( cin >> num )
{
int num_divide[15] = {0};
int value_no = 0;
int max_value = 0;

for(value_no=0;num>0;value_no++)
{
num_divide[value_no] = num % 10;
num /= 10;
}
max_value = value_no-1;

for( int i = max_value ; i >= 0 ; i-- )
{
if( num_divide[i] != 0 )
cout << number[num_divide[i]] << value[i];
else if( i == 4 || i == 8 )
cout << value[i];
else if( i==0 )
cout<<"";
else if( num_divide[i-1] != 0 )
cout << number[num_divide[i]];
}
cout << endl;
}
return 0;
}

Monday, July 25, 2011

a007. 判斷質數


#include
#include
using namespace std;

int main()
{
int input;
while( cin >> input )
{
if( input == 2 )
cout<<"質數"< else if( input % 2 == 0 )
cout<<"非質數"< else
{
int isPrime = 1;
for( int i = 3 ; i <= sqrt((double)input); i++ )
{
if( input % i == 0 )
{
cout<<"非質數"< isPrime = 0;
break;
}
}
if( isPrime )
cout<<"質數"< }
}

return 0;
}

a006. 一元二次方程式


#include
#include
using namespace std;

int main()
{
int a, b, c;
while( cin >> a >> b >> c )
{
int sqrtOfThis=sqrt((double)(b*b-4*a*c));
if( b*b - 4*a*c < 0 )
cout << "No real root\n";
else if( b*b - 4*a*c == 0 )
cout << "Two same roots x=" << -b/(2*a) << endl;
else
cout << "Two different roots x1=" << (-b + sqrtOfThis ) / (2*a)
<< " , x2=" << (-b - sqrtOfThis) / (2*a) << endl;
}
return 0;
}

a005. Eva 的回家作業


#include
using namespace std;

int main() {
double number , i1 , i2 , i3 , i4 ,i5 ;
while(cin >> number)
{
while(cin >> i1 >> i2 >> i3 >> i4 )
{
if((i2 - i1) == (i4 - i3))
{
i5 = i4 + (i4 - i3) ;
}
else
{
i5 = i4 * (i2/i1);
}
cout << i1 << " " << i2 << " " << i3 << " " << i4 << " " << i5 << endl ;
}
}
return 0;
}

a004: 文文的求婚


#include
using namespace std;

int main()
{
int year;
while( cin >> year )
{
if( ( year % 4 == 0 && year % 100 != 0 ) || (year % 400 == 0) )
cout << "閏年\n";
else
cout << "平年\n";
}
return 0;
}

a003: 兩光法師占卜術


#include
using namespace std;

int main()
{
int M,D,S;
while(cin>>M>>D)
{
S=(M*2+D)%3;
if(S==0)
{
cout<<"普通"< }
else if(S==1)
{
cout<<"吉"< }
else if(S==2)
{
cout<<"大吉"< }
}

return 0;
}

a002: 簡易加法


#include
using namespace std;

int main()
{
int i, j;
while( cin >> i >> j )
cout << i+j << endl;
return 0;
}

a001: 哈囉

 
#include
using namespace std;
int main() {
string s;
while(cin >> s){
cout << "hello, "<< s << endl;
}
return 0;
}

Wednesday, July 20, 2011

使用 SyntaxHighlighter

使用 SyntaxHighlighter

"儲存之後,張貼程式碼只要使用 這樣的語法將程式碼框住就可以了。"




.

Monday, July 18, 2011

a016. 數獨(SUDOKU) 尚未成功解出

 

// string::rbegin and string::rend
#include
#include
using namespace std;

void clear(int X[]);
void show(int X[]);
int check(int X[]);
void read(int X[9][9]);
int row_check(int X[9][9]);
int column_check(int X[9][9]);
int square_check(int X[9][9]);

int main ()
{
int A[9][9]={0};
int flag=1;

read(A);
//cout< flag = row_check(A) & flag;
flag = column_check(A) & flag;
flag = square_check(A) & flag;
if(flag) cout<<"yes"< else cout<<"no"< //system("pause");
return 0;
}

void show(int X[])
{
for(int i=0;i<9;i++)
{
cout< }
}
void clear(int X[])
{
for(int i=0;i<10;i++)
{
X[i]=0;
}
}
int check(int X[])
{
int R[10]={0};
int isOk=1;

for(int i=0; i<9; i++)
{
if(R[ X[i] ] ==0)
{
R[ X[i] ]=1;
}
else isOk=0;
}
return isOk;
}
void read(int X[9][9])
{
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
{
cin>>X[i][j];
}
}
}
int row_check(int X[9][9])
{
int flag=1;
int W[9]={0};
for(int i=0;i<9;i++)
{
for(int j=0;j<9;j++)
{
W[i]=X[i][j];
}
if(check(W)==0)
{
flag=0;
}
}
return flag;
}
int column_check(int X[9][9])
{
int flag=1;
int W[9]={0};
for(int j=0;j<9;j++)
{
for(int i=0;i<9;i++)
{
W[i]=X[i][j];
}
if(check(W)==0)
{
flag=0;
}
}
return flag;
}
int square_check(int X[9][9])
{
int flag=1;
int W[9]={0};
int count=0;
for(int i=0;i<9;i+3)
{
for(int j=0;j<9;j+3)
{
for(int i2=0;i2<3;i2++)
{
for(int j2=0;j2<3;j2++)
{
W[count]=X[i+i2][j+j2];
count++;
}
}

if(check(W)==0)
{
flag=0;
}
count=0;
}
}


return flag;
}