• 构造+暴力 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 }
    编译人生,运行世界!
  • 相关阅读:
    安装jdk
    chrome
    Jenkins启动
    Red Hat Linux分辨率调整
    Jemeter第一个实例
    grep与正则表达式
    使用ngx_lua构建高并发应用
    UML建模之时序图(Sequence Diagram)
    secureCRT mac 下破解
    跨域通信的解决方案JSONP
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4699090.html
Copyright © 2020-2023  润新知