zoukankan      html  css  js  c++  java
  • hdu 4350 2012 多校

    题意:一个长度为52的数组每次从中去[l,r]放到最前面,操作k次问你数组是什么样的。

    思路:由于k很大当时就想肯定要摸一个数,然后用样例打了个表发现只要模r就行了。是一道水题

    代码如下:

     1 /**************************************************
     2  * Author     : xiaohao Z
     3  * Blog     : http://www.cnblogs.com/shu-xiaohao/
     4  * Last modified : 2014-05-11 16:32
     5  * Filename     : A.cpp
     6  * Description     : 
     7  * ************************************************/
     8 
     9 #include <iostream>
    10 #include <cstdio>
    11 #include <cstring>
    12 #include <cstdlib>
    13 #include <cmath>
    14 #include <algorithm>
    15 #include <queue>
    16 #include <stack>
    17 #include <vector>
    18 #include <set>
    19 #include <map>
    20 #define MP(a, b) make_pair(a, b)
    21 #define PB(a) push_back(a)
    22 
    23 using namespace std;
    24 typedef long long ll;
    25 typedef pair<int, int> pii;
    26 typedef pair<unsigned int,unsigned int> puu;
    27 typedef pair<int, double> pid;
    28 typedef pair<ll, int> pli;
    29 typedef pair<int, ll> pil;
    30 
    31 const int INF = 0x3f3f3f3f;
    32 const double eps = 1E-6;
    33 const int LEN = 100;
    34 vector<int> cd, tcd;
    35 
    36 int main()
    37 {
    38 //    freopen("in.txt", "r", stdin);
    39 
    40     int t, n, l, r, tmp, kase = 1;
    41     cin >> t;
    42     while(t--){
    43         cd.clear();
    44         tcd.clear();
    45         for(int i=0; i<52; i++){
    46             cin >> tmp;
    47             cd.PB(tmp);
    48         }
    49         cin >> n >> l >> r;
    50         r--, l--;
    51         n %= r+1;
    52         for(int i=0; i<n; i++){
    53             stack<int> q;
    54             for(int j=l; j<=r; j++) q.push(cd[j]);
    55             for(int j=l; j<=r; j++) cd.erase(cd.begin()+l);
    56             while(!q.empty()){
    57                 cd.insert(cd.begin(), q.top());
    58                 q.pop();
    59             }
    60         }
    61         printf("Case #%d: ", kase ++);
    62         for(int i=0; i<52; i++){
    63             printf("%d", cd[i]);
    64             if(i != 51) printf(" ");
    65             else printf("
    ");
    66         }
    67     }
    68     return 0;
    69 }
    View Code
  • 相关阅读:
    redis
    java基础知识起步
    SQL(DML)语法
    jsp中的九大内置对象和四大作用域
    JDBC与javaBean
    javaScript知识点大全
    mysql数据库操作语法大全
    css前端知识点总结
    HTML前端小结
    代码整洁之道
  • 原文地址:https://www.cnblogs.com/shu-xiaohao/p/3722481.html
Copyright © 2011-2022 走看看