zoukankan      html  css  js  c++  java
  • 构造+暴力 Codeforces Round #283 (Div. 2) B. Secret Combination

    题目传送门

     1 /*
     2     构造+暴力:按照题目意思,只要10次加1就变回原来的数字,暴力枚举所有数字,string大法好!
     3 */
     4 /************************************************
     5 Author        :Running_Time
     6 Created Time  :2015-8-3 8:43:02
     7 File Name     :A.cpp
     8 *************************************************/
     9 
    10 #include <cstdio>
    11 #include <algorithm>
    12 #include <iostream>
    13 #include <sstream>
    14 #include <cstring>
    15 #include <cmath>
    16 #include <string>
    17 #include <vector>
    18 #include <queue>
    19 #include <deque>
    20 #include <stack>
    21 #include <list>
    22 #include <map>
    23 #include <set>
    24 #include <bitset>
    25 #include <cstdlib>
    26 #include <ctime>
    27 using namespace std;
    28 
    29 #define lson l, mid, rt << 1
    30 #define rson mid + 1, r, rt << 1 | 1
    31 typedef long long ll;
    32 const int MAXN = 1e3 + 10;
    33 const int INF = 0x3f3f3f3f;
    34 const int MOD = 1e9 + 7;
    35 string mn, now, str;
    36 int n;
    37 
    38 int main(void)    {       //Codeforces Round #283 (Div. 2) B. Secret Combination
    39     while (cin >> n)   {
    40         cin >> str;   mn = str; now = str;
    41         for (int i=1; i<=10; ++i)   {
    42             for (int j=0; j<n; ++j)  {
    43                 if (now[j] == '9')  now[j] = '0';
    44                 else    now[j]++;
    45             }
    46             cout << now << endl;
    47             for (int j=0; j<n; ++j) {
    48                 string tmp = "";
    49                 for (int k=j; k<n; ++k) tmp += now[k];
    50                 for (int k=0; k<j; ++k) tmp += now[k];
    51                 if (tmp < mn)   mn = tmp;
    52             }
    53         }
    54         cout << mn << endl;
    55     }
    56 
    57     return 0;
    58 }
    编译人生,运行世界!
  • 相关阅读:
    【今日CV 视觉论文速览】 19 Nov 2018
    【numpy求和】numpy.sum()求和
    【今日CV 视觉论文速览】16 Nov 2018
    【今日CV 视觉论文速览】15 Nov 2018
    poj 2454 Jersey Politics 随机化
    poj 3318 Matrix Multiplication 随机化算法
    hdu 3400 Line belt 三分法
    poj 3301 Texas Trip 三分法
    poj 2976 Dropping tests 0/1分数规划
    poj 3440 Coin Toss 概率问题
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4699090.html
Copyright © 2011-2022 走看看