Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:求助我和网上找来的代码大同小异,提交之后他的每次都AC,我把数据和语句风格改的都跟他差不多了但还是WA……rpIn Reply To:求助我和网上找来的代码大同小异,提交之后他的每次都AC,我把数据和语句风格改的都跟他差不多了但还是WA……rp Posted by:tankadozmy at 2010-02-04 15:42:46 > #include <iostream> //这是他的 > #include <ctime> > using namespace std; > long n,i,j,m,s,k,a[505][505],b[505][505],c[505][505],sum; > int main() > { > > srand((unsigned)time(0));//初始化随机函数 > > while(cin>>n) > { > k=0; > for(i=0;i<n;i++) > for(j=0;j<n;j++) > scanf("%d",&a[i][j]); > for(i=0;i<n;i++) > for(j=0;j<n;j++) > scanf("%d",&b[i][j]); > > for(i=0;i<n;i++) > for(j=0;j<n;j++) > scanf("%d",&c[i][j]); > > for(s=0;s<60000;s++) //随机次数越多越准确 > { > > j=rand()%n; //随机抽取行列 > i=rand()%n; > > sum=0; > for(m=0;m<n;m++) > sum+=a[i][m]*b[m][j]; > if(c[i][j]!=sum) { k=1;break;} > > } > > > > > if(k==1) cout<<"NO"<<endl; > else > cout<<"YES"<<endl; > > > } > > > return 0; > } > #include<iostream> //这是我的 > #include<ctime> > using namespace std; > int main() > { > int n; > srand((unsigned int)time(0)); > > long int a[505][505],b[505][505],d[505][505]; > int i,j; > while(cin>>n) > { > int t=60000,flag=0; > for(i=0;i<n;i++) > for(j=0;j<n;j++) > scanf("%d",&a[i][j]); > for(i=0;i<n;i++) > for(j=0;j<n;j++) > scanf("%d",&b[i][j]); > for(i=0;i<n;i++) > for(j=0;j<n;j++) > scanf("%d",&d[i][j]); > > int r,c; > while (t) > { > r=rand()%n; > c=rand()%n; > long int temp=0; > for(i=0;i<n;i++) > { > temp+=a[r][i]*b[i][c]; > } > if(temp!=d[r][c]) {flag=1; break;} > t--; > } > if(flag) > { > cout<<"NO"<<endl; > } > else > cout<<"YES"<<endl; > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator