<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                題目鏈接:[點擊打開鏈接](http://poj.org/problem?id=2886) 題意:一共n個人, 從第k個人開始, 這個人離隊并且指定向左或向右第v個人離隊, 依次下去, 求得分最高的人是誰。 第p個人離隊, 將得到G(p)分, G(p)是可以整除p的所有數。 對于可以被i整除的數的個數, 我們可以通過枚舉每一個數的倍數, 預先處理出來。 該題直接模擬就好, 因為每次都一定有一個人出隊, 所以要枚舉n次 , 對于每次, 要計算具體是哪個人出隊, 這個可以用數學推導很快的算出來是當前隊列的第幾個人, 要找到這個人我們可以用二分+樹狀數組來優化算法。? 復雜度O(n*logn*logn) 細節參見代碼: ~~~ #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<stack> #include<bitset> #include<cstdlib> #include<cmath> #include<set> #include<list> #include<deque> #include<map> #include<queue> #define Max(a,b) ((a)>(b)?(a):(b)) #define Min(a,b) ((a)<(b)?(a):(b)) using namespace std; typedef long long ll; const double PI = acos(-1.0); const double eps = 1e-6; const int INF = 1000000000; const int maxn = 500000 + 10; int T,n,k,m,cnt[maxn] = {0},bit[maxn]; struct node { char s[20]; int v; }a[maxn]; int sum(int x) { int ans = 0; while(x > 0) { ans += bit[x]; x -= x & -x; } return ans; } void add(int x, int d) { while(x <= n) { bit[x] += d; x += x & -x; } } void init() { for(int i=1;i<=500000;i++) { for(int j=i;j<=500000;j+=i) { cnt[j]++; } } } int erfen(int x) { int l = 1, r = n, mid; while(r > l) { mid = (r + l) >> 1; if(sum(mid) >= x) r = mid; else l = mid + 1; } return r; } int main() { init(); while(~scanf("%d%d",&n,&k)) { memset(bit, 0, (n+1)*sizeof(bit[0])); int maxv = cnt[1]; for(int i=1;i<=n;i++) { scanf("%s%d",a[i].s,&a[i].v); maxv = max(maxv, cnt[i]); add(i, 1); } int now = k, nxt = k, _cnt = 1; while(true) { int nn = n - _cnt; m = a[now].v; if(cnt[_cnt] == maxv) { printf("%s %d\n",a[now].s,cnt[_cnt]); break; } if(m > 0) nxt = (nxt - 1 + m % nn) % nn; else nxt = ((nxt + m)%nn + nn)%nn; if(nxt == 0) nxt = nn; add(now, -1); now = erfen(nxt); _cnt++; } } return 0; } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看