zoukankan      html  css  js  c++  java
  • poj3125

    简单题

    View Code
    #include <iostream>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cstdio>
    #include
    <algorithm>
    using namespace std;

    #define maxn 105

    int n, m;
    int f[maxn];
    int g[maxn];
    bool vis[maxn];

    void input()
    {
    scanf(
    "%d%d", &n, &m);
    for (int i = 0; i < n; i++)
    scanf(
    "%d", &f[i]);
    memcpy(g, f,
    sizeof(g));
    }

    void work()
    {
    int ans = 0;
    memset(vis,
    0, sizeof(vis));
    int pos = 0;
    int i = n - 1;
    while (!vis[m])
    {
    while (f[pos % n] != g[i])
    pos
    ++;
    pos
    %= n;
    vis[pos]
    = true;
    i
    --;
    ans
    ++;
    pos
    ++;
    }
    printf(
    "%d\n", ans);
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    int t;
    scanf(
    "%d", &t);
    while (t--)
    {
    input();
    sort(g, g
    + n);
    work();
    }
    return 0;
    }
  • 相关阅读:
    Properties类
    缓冲流
    Mybatis
    分页查询
    QueryRunner和JDBC连接池
    JSP
    Session
    Cookie
    http协议和eclipes绑定tomcat
    servlet
  • 原文地址:https://www.cnblogs.com/rainydays/p/2178019.html
Copyright © 2011-2022 走看看