# 清华大学历年考研复试机试真题 - 等差数列

Time Limit: 1000 ms
Memory Limit: 256 mb

3 4
1 2 0 0
0 0 0 0
3 0 0 0

1 3 3
1 4 4
2 1 2

#include <stdio.h>
#include <string.h>
#define INF 0x3f3f3f3f	//写成0x7fffffff就不对了
typedef struct record{
int num;
int sit;
}rec;
int main(){
int n,m,i,j;
scanf("%d %d",&n,&m);
int a[n+1][m+1],t[n+1],p[m+1],r[n+1],c[m+1];
rec row[n+1][2],col[m+1][2];
memset(a,0,sizeof(a));
memset(row,0,sizeof(row));
memset(col,0,sizeof(col));
memset(t,0,sizeof(t));
memset(p,0,sizeof(p));
memset(r,INF,sizeof(r));
memset(c,INF,sizeof(c));
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
scanf("%d",&a[i][j]);
if(a[i][j]!=0){
if(t[i]<2){
row[i][t[i]].num=a[i][j];
row[i][t[i]].sit=j;
t[i]++;
if(t[i]==2) r[i]=(row[i][0].num-row[i][1].num)/(row[i][0].sit-row[i][1].sit);
}
if(p[j]<2){
col[j][p[j]].num=a[i][j];
col[j][p[j]].sit=i;
p[j]++;
if(p[j]==2) c[j]=(col[j][0].num-col[j][1].num)/(col[j][0].sit-col[j][1].sit);
}
}
}
}
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
if(a[i][j]==0){
if(r[i]!=INF) printf("%d %d %d\n",i,j,row[i][0].num-r[i]*(row[i][0].sit-j));
else if(c[j]!=INF) printf("%d %d %d\n",i,j,col[j][0].num-c[j]*(col[j][0].sit-i));
}
}
}
return 0;
}


08-23 2万+
03-21 5757
03-19 3060
06-30 2570
10-26 1250
09-19 974
02-07 593
03-23 6万+
09-18 3520
10-19 487
03-24 4万+
12-25 4809
08-05 1360
09-15 2515