Codeforces Round #347 (Div. 1) B. International Olympiad
来源:互联网 发布:仟游软件科技有限公司 编辑:程序博客网 时间:2024/04/30 21:54
International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of formIAO'y, where y stands for some number of consequent last digits of the current year. Organizers always pick an abbreviation with non-empty stringy 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 abbreviationsIAO'9, IAO'0 andIAO'1, while the competition in 2015 received an abbreviationIAO'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.
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.
For each abbreviation given in the input, find the year of the corresponding Olympiad.
5IAO'15IAO'2015IAO'1IAO'9IAO'0
201512015199119891990
4IAO'9IAO'99IAO'999IAO'9999
1989199929999999分析:找规律。#include <cstdio>#include <stdlib.h>#include <cstring>#include <iostream>using namespace std;int n;char a,b,c,d,s[11];long long f[10] = {0,0,0,0,3099,13099,113099,1113099,11113099,111113099}; int main(){cin.sync_with_stdio(false);cin>>n;for(int i = 1;i <= n;i++){cin>>a>>b>>c>>d;cin>>s;int l = strlen(s);if(l <= 3){if(l == 1) {if(atoi(s) == 9) cout<<1989<<endl;else cout<<199<<s<<endl;}if(l == 2){if(atoi(s) == 99) cout<<1999<<endl;else cout<<20<<s<<endl;}if(l == 3){if(atoi(s) < 99) cout<<3<<s<<endl;else cout<<2<<s<<endl;}}else{if(atol(s) < f[l]) cout<<1<<s<<endl;else cout<<s<<endl;}} }
- Codeforces Round #347 (Div. 1) B. International Olympiad
- codeforces round#347 div2 C International Olympiad 想法题
- Codeforces Round #347 (Div. 2) C. International Olympiad(求第一次出现这种数字结尾的是哪一个年份)
- Codeforces Round #306 (Div. 2) B. Preparing Olympiad
- Codeforces Round #306 (Div. 2)B. Preparing Olympiad--状态压缩
- Codeforces Round #306 (Div. 2) B. Preparing Olympiad
- Codeforces Round #306 (Div. 2) B.Preparing Olympiad (位运算)
- Codeforces Round #306 (Div. 2) B. Preparing Olympiad dfs
- Codeforces Round #306 (Div. 2) B. Preparing Olympiad (状态压缩)
- Codeforces Round #441 (Div. 1, by Moscow Team Olympiad)
- Codeforces Round #433(Div. 1,based on Olympiad of Metropolises)A Planning B Jury Meeting C Boredom
- Codeforces 664C:International Olympiad
- codeforces 662D International Olympiad
- codeforces 306 div.2 B. Preparing Olympiad
- CF #347 (Div.2) C. International Olympiad(模拟)
- Codeforces Round #306 (Div. 2) B. Preparing Olympiad (二进制枚举)
- Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) B. Maxim Buys an Apartment
- Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) A,B,C
- 2.结构型.6.桥接模式
- (经典)POJ-3181 完全背包+大数处理
- [acm.sgu.ru]101. Domino
- 引导页添加炫酷动画
- 2.结构型.7.享元模式
- Codeforces Round #347 (Div. 1) B. International Olympiad
- JUnit4注解基本介绍
- iOS更改工程的根控制器
- 函数原型,函数声明,函数定义,他们的三角关系
- 机器学习中使用的神经网络第五讲笔记
- DOM事件流
- JAVA面试之消费者-生产者问题
- Sass 环境调试
- java线程通信