zoukankan      html  css  js  c++  java
  • 2017年浙工大迎新赛热身赛 L cayun日常之赏月【易错特判】

    题目描述(https://www.nowcoder.com/acm/contest/51#question)

    在cayun星球月亮大小都有一个规律,月亮为每30天一个周期,在这30天的周期里,月亮的大小分别为0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,虽然天气很冷,但某个cayun今天却异常疯癫,不知为何居然想要赏月了。但他想在赏月之前知道今天的月亮到底有多大。

    输入描述:

    第一行数据组数T(T <= 30),
    对于每组数据两个整数a, b(0 <= a, b <= 15),表示前两天的月亮大小,保证数据是合法的。

    输出描述:

    每组数据占一行,表示今天的月亮大小。
    示例1

    输入

    2
    0 1
    11 10

    输出

    2
    9
    【分析】:注意14 15->14以及1,0->1
    【代码】:
    // 2017年浙工大迎新赛热身赛
    #include <bits/stdc++.h>
    using namespace std;
    int t,n,m;
    
    int main()
    {
        cin>>t;
        while(t--)
        {
            cin>>n>>m;
            if(n==14&&m==15)
            {
                printf("14
    ");
            }
            if(n==1&&m==0)
            {
                printf("1
    ");
            }
            if(n<m&&(n!=14&&m!=15)) printf("%d
    ",m+1);
            if(n>m&&(n!=1&&m!=0)) printf("%d
    ",m-1);
        }
    }
    

      

  • 相关阅读:
    CentOS配置bond
    rsync 06-sersync文件实时同步
    rsync 07-confxml.xml配置文件
    rsync 04-rsyncd启动脚本
    rsync 03-rsyncd.conf配置文件
    rsync 01-rsync命令使用
    rsync 02-部署rsync的daemon模式
    CentOS7升级OpenSSH
    iptables 02-CentOS7.x 启用iptables
    iptables 01-iptables命令
  • 原文地址:https://www.cnblogs.com/Roni-i/p/8007228.html
Copyright © 2011-2022 走看看