一道简单的规律题,画出二维表将数字分别相加可以发现很明显的对称性
题目链接:http://www.bnuoj.com/v3/problem_show.php?pid=24251
1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 #include<iostream> 5 #include<math.h> 6 using namespace std; 7 8 int main() 9 { 10 int sum,n,m,Num,i,t; 11 scanf("%d",&sum); 12 for(i=1;i<=sum;i++) 13 { 14 scanf("%d %d",&n,&m); 15 if(n>m) 16 { 17 int x=n; 18 n=m; 19 m=x; 20 } 21 scanf("%d",&t); 22 printf("Case #%d: ",i); 23 while(t--) 24 { 25 scanf("%d",&Num); 26 if(Num>n+m) 27 printf("0 "); 28 else if(Num>n && Num>m) 29 printf("%d ",n+m-Num+1); 30 else if(Num<=n && Num<=m) 31 { 32 if(Num == 0) 33 printf("0 "); 34 else 35 printf("%d ",Num-1); 36 } 37 else if(Num>n && Num<=m) 38 { 39 printf("%d ",n); 40 } 41 else if(Num==n && Num<=m) 42 { 43 printf("%d ",n-1); 44 } 45 46 } 47 48 } 49 return 0; 50 }