• HDU


    题意:有n双袜子,编号1到n,放在衣柜里,每天早晨取衣柜中编号最小的袜子穿,晚上将这双袜子放在篮子里,当篮子里有n-1双袜子时,清洗袜子,直到第二天晚上才洗好,并将洗好的袜子重新放回衣柜。

    分析:规律为

    1、n=2时,1 2 1 2 1 2 1 2……

    2、n=3时,1 2 3 1 2 1 3 1 2 1 3……

    3、n=4时,1 2 3 4 1 2 3 1 2 4 1 2 3 1 2 4……

    4、n=5时,1 2 3 4 5 1 2 3 4 1 2 3 5 1 2 3 4 1 2 3 5……

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<cmath>
    #include<iostream>
    #include<sstream>
    #include<iterator>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<set>
    #include<map>
    #include<stack>
    #include<deque>
    #include<queue>
    #include<list>
    #define lowbit(x) (x & (-x))
    const double eps = 1e-8;
    inline int dcmp(double a, double b){
        if(fabs(a - b) < eps) return 0;
        return a > b ? 1 : -1;
    }
    typedef long long LL;
    typedef unsigned long long ULL;
    const int INT_INF = 0x3f3f3f3f;
    const int INT_M_INF = 0x7f7f7f7f;
    const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
    const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
    const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
    const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
    const int MOD = 1e9 + 7;
    const double pi = acos(-1.0);
    const int MAXN = 10000 + 10;
    const int MAXT = 10000 + 10;
    using namespace std;
    int main(){
        LL n, k;
        int kase = 0;
        while(scanf("%lld%lld", &n, &k) == 2){
            printf("Case #%d: ", ++kase);
            if(k <= n){
                printf("%lld
    ", k);
                continue;
            }
            LL a = (k - n) / (n - 1);
            LL b = (k - n) % (n - 1);
            if(b != 0){
                printf("%lld
    ", b);
            }
            else{
                if(a & 1){
                    printf("%lld
    ", n - 1);
                }
                else{
                    printf("%lld
    ", n);
                }
            }
        }
        return 0;
    }
    

      

  • 相关阅读:
    vue中插槽的理解
    父子组件的通信
    vue3.0怎么禁用eslint校验代码和修改端口号
    三大排序
    让机器人实现自主行走 没你想的那么难
    国内外知名激光雷达公司盘点
    激光雷达寿命短,思岚通过什么技术来解决?
    浅谈SLAM的回环检测技术
    除了ROS, 机器人定位导航还有其他方案吗?
    思岚科技即将登陆“2018日本机器人周”精彩抢先看
  • 原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/7236355.html
Copyright © 2020-2023  润新知