C. International Olympiad

54 篇文章 0 订阅

C. International Olympiad
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where y stands for some number of consequent last digits of the current year. Organizers always pick an abbreviation with non-empty string y that has never been used before. Among all such valid abbreviations they choose the shortest one and announce it to be the abbreviation of this year's competition.

For example, the first three Olympiads (years 1989, 1990 and 1991, respectively) received the abbreviations IAO'9IAO'0 and IAO'1, while the competition in 2015 received an abbreviation IAO'15, as IAO'5 has been already used in 1995.

You are given a list of abbreviations. For each of them determine the year it stands for.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of abbreviations to process.

Then n lines follow, each containing a single abbreviation. It's guaranteed that each abbreviation contains at most nine digits.

Output

For each abbreviation given in the input, find the year of the corresponding Olympiad.

Examples
input
5
IAO'15
IAO'2015
IAO'1
IAO'9
IAO'0
output
2015
12015
1991
1989
1990
input
4
IAO'9
IAO'99
IAO'999
IAO'9999
output
1989
1999
2999
9999

题意:告诉你一个比赛是从1989年开始举办的,然后我们采用一种缩写形式。比如1989采用9,1990采用0.

然后就是已经使用过的不能再使用了,比如说1999就需要采用99了。

然后给你缩写,让你写出对应的年份。

这个题一直往下写就可以了,然后大约到第4位开始就有个规律,直接分类讨论就可以了。

#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
const long long inf = 1e9;
const int MAXN = 1e5+7;
int n;
string get_ans(string num)
{
    int l = num.size();
    if(l == 1)
    {
        if(num == "9")return "1989";
        else return "199"+num;
    }
    else if(l == 2)
    {
        if(num == "99")return "1999";
        else return "20"+num;
    }
    else if(l == 3)
    {
        if(num == "099")return "2099";
        else if(num[0] == '0')return "3"+num;
        else return "2"+num;
    }
    else if(l == 4)
    {
        if(num>="3099")return num;
        else return "1"+num;
    }
    else if(l == 5)
    {
        if(num>="13099")return num;
        else return "1"+num;
    }
    else if(l == 6)
    {
        if(num>="113099")return num;
        else return "1"+num;
    }
    else if(l == 7)
    {
        if(num>="1113099")return num;
        else return "1"+num;
    }
    else if(l == 8)
    {
        if(num>="11113099")return num;
        else return "1"+num;
    }
    else if(l == 9)
    {
        if(num>="111113099")return num;
        else return "1"+num;
    }
    return "";
}
int main()
{
    scanf("%d",&n);
    string s;
    for(int i = 0 ; i < n ; ++i)
    {
        cin>>s;
        s = s.substr(4,s.size());
        cout << get_ans(s) << endl;
    }
    return 0;

}







  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个问题需要使用Python中的Bokeh库来设计交互式图表。首先,我们需要导入Bokeh库和数据集,并创建一个Figure对象来设置坐标轴和图表大小: ```python from bokeh.plotting import figure, show from bokeh.models import ColumnDataSource, HoverTool import pandas as pd # 导入数据集 df = pd.read_csv('olympic_data.csv') # 创建ColumnDataSource对象 source = ColumnDataSource(data=dict( x=df['Medal_Count'], y=df['Athlete_Count'], sport=df['Sport'], medal_type=df['Medal'], athlete_name=df['Name'], nationality=df['Nationality'], gender=df['Sex'] )) # 创建Figure对象 p = figure(title="2016 Rio Olympics Medal Count vs Athlete Count", x_axis_label='Medal Count', y_axis_label='Athlete Count', plot_width=800, plot_height=600) ``` 接下来,我们需要使用scatter()方法将数据点绘制到图表上,并设置颜色和大小,以及添加悬停工具: ```python # 绘制散点图 p.scatter('x', 'y', source=source, size=10, alpha=0.8, color='medal_type', legend_group='sport') # 添加悬停工具 hover = HoverTool(tooltips=[ ('Athlete Name', '@athlete_name'), ('Sport', '@sport'), ('Nationality', '@nationality'), ('Gender', '@gender'), ('Medal Type', '@medal_type') ]) p.add_tools(hover) # 设置图例位置 p.legend.location = "top_left" # 显示图表 show(p) ``` 这样,我们就可以得到一个交互式的散点图,可以通过滑动控件来筛选所显示的大项,悬停于数据点上时可以查看更多信息。 需要注意的是,上述代码中的数据集需要根据实际情况进行调整和更改,以适应所需的数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值