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

30L精髓16ms在线算法

Posted by kill_myself at 2011-07-14 21:47:25 on Problem 1068
#include<iostream>
#include<string.h>
using namespace std;
int a[101];
int main()
{
    int n,m,bf,x,t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        bf=0;
        memset(a,0,sizeof(a));
        while(n--)
        {
           cin>>m;
           bf=m;
           while(a[m])
           {
             m-=a[m];
             a[bf]+=a[m];
           }
           a[bf]++;
           cout<<a[bf]<<' ';
           
        }
        cout<<endl;
    }
}

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