Thinking the problem is solved

1. Description of the problem: the length n of the number of columns (the number of elements of the column is 1 ~ n), which is selected from the m number of special, additional treatment of the paging number of columns (the length of each page is k)

Every one of us in all the special digital cleanup process, from the beginning through each page, clear digital special page, in addition to clearing the numbers, all the numbers will move forward behind the bench. Seeking to deal with the number of times (including the number of pages of special digital Clear)

For example:

n=10  m=4   k=5

1 2 3 4 5 | 6 7 8 9 10

Wherein the unique word is 2479

First processing: processing a first page number of the 2,4 row becomes:. 3. 1. 5. 6 . 7 | . 8 . 9 10

Second process: 7 the processed first column to page:. 1. 5. 6. 8. 3 |. 9 10

Third process: 9 the processed second column to page: 1 3 5 6 8 | 10

It is necessary to deal with three

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vector<long long> v(m);
    for(ll i=0;i<m;i++)
       cin>>v[i];
    ll t=0,r=0;
    while(t<m)
    {
        ll h=((v[t]-t+k-1)/k)*k+t;//该页的最后一个数字
        while(V [t] <= t && H < m) 
        { 
            t ++; // value t representing This page contains a special digital number 
        } 
        R & lt ++ ; 
    } 
     COUT << R & lt << endl; 
}

 

Guess you like

Origin www.cnblogs.com/Aiahtwo/p/11184480.html
Recommended