hdu 4350 2012 多校 - 6
生活随笔
收集整理的這篇文章主要介紹了
hdu 4350 2012 多校 - 6
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題意:一個長度為52的數組每次從中去[l,r]放到最前面,操作k次問你數組是什么樣的。
思路:由于k很大當時就想肯定要摸一個數,然后用樣例打了個表發(fā)現只要模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("\n"); 66 } 67 } 68 return 0; 69 } View Code?
轉載于:https://www.cnblogs.com/shu-xiaohao/p/3722481.html
總結
以上是生活随笔為你收集整理的hdu 4350 2012 多校 - 6的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: js快速判断IE浏览器(兼容IE10与I
- 下一篇: 黑盒测试用例大集