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

ac代码

Posted by zjut020 at 2009-02-25 19:48:11 on Problem 3665
#include<iostream>
#include<fstream>
#include<cmath>
using namespace std;
int main()
{
    //ifstream cin("0.txt");
    
    int n,i,t,r[1005];cin>>n>>t;
    for(i=1;i<=n;i++)
    cin>>r[i];
    
    for(int j=0;j<t;j++)
    {
          int max=-1,index;
          for(i=1;i<=n;i++)
          if(r[i]>max)
          {
              max=r[i];
              index=i;            
          }  
          cout<<index<<endl;
          int add=r[index]/(n-1);
          int mod=r[index]%(n-1);
          for(i=1;i<=n;i++)
          r[i]+=add;
          for(i=1;i<=mod;i++)
          {
               r[i]++;
               if(i==index)
               mod++;                
          }
          r[index]=0; 
    }
   // system("pause");
    return 0;  
}

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