H-纪年-牛客小白月赛3

链接:https://www.nowcoder.com/acm/contest/87/H
来源:牛客网

题目描述
Cwbc和XHRlyb在学习干支纪年法。
干支纪年法是中国历法上自古以来就一直使用的纪年方法。干支是天干和地支的总称。甲、乙、丙、丁、戊、己、庚、辛、壬、癸等十个符号叫天干;子、丑、寅、卯、辰、巳、午、未、申、酉、戌、亥等十二个符号叫地支。
为了方便程序的书写,我们不妨将天干记做1到10,地支记做1到12。
通过查阅日历,Cwbc知道农历2018年是戊戌年,XHRlyb想知道农历的n年是什么年。
0年指1年的前一年。
聪明的你在仔细阅读题目后,一定可以顺利的解决这个问题!
输入描述:
输入数据有多组数据,每行有一个整数,表示n。
输出描述:
输出数据应有多行,每行两个整数,分别表示天干和地支的编号。
示例1
输入

2018
输出

5 11
示例2
输入

2020
输出

7 1
备注:
n ∈ [0, 1018]。
1 ≤ T ≤ 1000。

[分析]
百度
然后模拟

[代码]

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    while (scanf("%lld", &n) != EOF)
    {
        int a = n % 10;
        int b = n % 12;
        a = (a - 3 + 10) % 10;
        if (a == 0)a = 10;
        b = (b - 3 + 12) % 12;
        if (b == 0)b = 12;
        printf("%d %d\n", a, b);
    }
}

猜你喜欢

转载自blog.csdn.net/q435201823/article/details/80295563