Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:找不出问题啊。。。为什么wa呢?

Posted by 00348318 at 2005-12-23 04:21:28 on Problem 1282
In Reply To:找不出问题啊。。。为什么wa呢? Posted by:00348318 at 2005-12-23 04:20:18
过了的能说一下有什么要注意么?

//ACM_1282_庆典的日期
//wesley 2005.12.23 

#include <iostream.h>
#include <stdlib.h> 

int main()
{
    int n,p;
    int box[202][202],room[202],temproom[202];
    int i,j;
    int point,tag,outputtag;
    double year;
     
    cin>>n>>p;
    
    for (i=1;i<=n;i++)
        for (j=0;j<p;j++)
            cin>>box[i][j];      //输入初始数据 
    
    for (i=1;i<=n;i++)
        room[i]=i;               //初始化每个房间里的祭祀号码
    
    outputtag=0;        
    point=0;                     //初始化轮盘指针号  
    year=0;                      //初始化年份 
    
    while (year<=1000000000)
    {
        tag=0;                   //标记位归零
        
        for (i=1;i<=n;i++)
        {
            if (room[i]!=i)
            {
                tag=1; 
                break;
            }   //若非房间号与祭祀号均对应,则tag置1
        }   
         
        if (year!=0&&tag==0)
        {
            cout<<(long)year<<endl;  //若房间号与祭祀号对应,且非第0年,则输出该年份 
            outputtag=1; 
            break;
        }
        
        for (i=1;i<=n;i++)
            temproom[box[i][point]]=room[i];
        for (i=1;i<=n;i++)
            room[i]=temproom[i];     //每个祭祀到下一年的房间中 
        
        point=(point+p-1)%p;         //轮盘指针逆时针转一位 
     
        year++;                      //年份加1 
    }
    
    if (outputtag==0)
    {
        cout<<"No one knows."<<endl; 
    }        
    system ("pause"); 
}                   
         

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator