2032 杨辉三角
1 #include <stdio.h>
2
3 int main(){
4 int s[31][31],i,j,n;
5 while(~scanf("%d",&n)){
6 for(i=0;i<n;i++){
7 for(j=0;j<=i;j++){
8 if(j==0 || j==i){s[i][j]=1;}
9 else{s[i][j]=s[i-1][j]+s[i-1][j-1];}
10 }
11 }
12 for(i=0;i<n;i++){
13 for(j=0;j<=i;j++){
14 if(j==i){printf("%d
",s[i][j]);}
15 else{printf("%d ",s[i][j]);}
16 }
17 }
18 printf("
");
19 }
20 }
2040 亲和数
1 #include <stdio.h>
2
3 int qhs(int a){
4 int i,j,sum,s[50];
5 s[0]=1;j=1;
6 for(i=2;i<=a/2;i++){
7 if(a%i==0){s[j]=i;j++;}
8 }
9 sum=0;
10 for(i=0;i<j;i++){sum += s[i];}
11 return sum;
12 }
13
14 int main(){
15 int n,i,a,b,c,s[100];
16 while(scanf("%d",&n)!=EOF){
17 while(n--){
18 scanf("%d %d",&a,&b);
19 if(qhs(a)==b || qhs(b)==a){printf("YES
");}
20 else{printf("NO
");}
21 }
22 }
23 }
2042 不容易系列之二
1 #include <stdio.h>
2
3 int main(){
4 int n,m,i;
5 while(scanf("%d",&n)!=EOF){
6 while(n--){
7 scanf("%d",&m);
8 i = 3;
9 while(m--){i = (i-1)*2;}
10 printf("%d
",i);
11 }
12
13 }
14 }
2054 A == B ?
#include<stdio.h>
#include<string.h>
char a[100000],b[100000];
void change(char s[])
{
int len,i;
len=strlen(s);
if(strstr(s,"."))
{
for(i=len-1;s[i]=='0';i--)
{
s[i]='