博客
关于我
PAT Basic Level 1008 数组元素循环右移问题 (思维)
阅读量:266 次
发布时间:2019-03-01

本文共 1040 字,大约阅读时间需要 3 分钟。

???????????????????????????????

  • ????????????m = m % n????????????
  • ??????????????????????
  • ???m??????m?????????????
  • ?????????????????????????
  • ???????????O(n)????????????

    ?????

    ?????

    ????A???N?N>0??????????????????????????????M?M?0???????A??????A0 A1??AN-1?????AN-M ?? AN-1 A0 A1??AN-M-1????M??????????M??????????????????????????????????

    ?????

    ??

    6 2

    1 2 3 4 5 6

    ??

    5 6 1 2 3 4

    ?????

    ??????????????n????????m??????????????m????????n-m?????m>n???m?n??????????????????

    ???

    #include 
    #include
    #include
    using namespace std;int main() { int n, m; cin >> n >> m; vector
    arr(n); for(int i=0; i < n; i++) { cin >> arr[i]; } m %= n; if(m != 0) { reverse(arr.begin(), arr.begin() + n); reverse(arr.begin(), arr.begin() + m); reverse(arr.begin() + m, arr.begin() + n); } for(int i=0; i < n; i++) { cout << arr[i]; } return 0;}

     

     

    转载地址:http://lolx.baihongyu.com/

    你可能感兴趣的文章
    OA项目之我的会议(查询)
    查看>>
    OA项目之我的审批(会议查询&会议签字)
    查看>>
    OA项目之项目简介&会议发布
    查看>>
    ObjC的复制操作
    查看>>
    Object c将一个double值转换为时间格式
    查看>>
    object detection之Win10配置
    查看>>
    object detection训练自己数据
    查看>>
    object detection错误Message type "object_detection.protos.SsdFeatureExtractor" has no field named "bat
    查看>>
    object detection错误之Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
    查看>>
    object detection错误之no module named nets
    查看>>
    Object of type 'ndarray' is not JSON serializable
    查看>>
    Object Oriented Programming in JavaScript
    查看>>
    object references an unsaved transient instance - save the transient instance before flushing
    查看>>
    Object 类的常见方法有哪些?
    查看>>
    Object-c动态特性
    查看>>
    Object.assign用法
    查看>>
    Object.create
    查看>>
    Object.defineProperty详解
    查看>>
    Object.keys()的详解和用法
    查看>>
    objectForKey与valueForKey在NSDictionary中的差异
    查看>>