题目链接:

http://codeforces.com/contest/664/problem/C

题解:

这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99-98),三位的有2099-3098(099-098),四位的有3099-13098(3099-3098)

所以关键字长度一样的会连续出现,1989+0代表一位的开始,1989+10代表两位的开始,1989+10+100代表三位的开始,

现在给你一个长度为len的标志,就可以找出该数位的起始位置1989+10+100+...+10^(len-1),终止位置为1989+10+100+...+10^len-1,这个数位里面前len位固定的数是唯一的,完全可以马上找到。

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; char str[]; int ten[];
void pre() {
ten[] = ;
for (int i = ; i < ; i++) ten[i] = ten[i - ] * ;
//for (int i = 0; i < 10; i++) printf("ten:%d\n", ten[i]);
} int main() {
pre();
int tc;
scanf("%d", &tc);
while (tc--) {
scanf("%s", str);
int len = strlen(str) - ;
int x = ;
for (int i = ; i < len + ; i++) x = x * + str[i] - '';
int tmp = ;
for (int i = ; i < len; i++) {
tmp += ten[i];
}
if (x < tmp%ten[len]) tmp += ten[len];
printf("%d\n", tmp/ten[len]*ten[len]+x);
}
return ;
}

Codeforces Round #347 (Div. 2) C. International Olympiad 找规律的更多相关文章

  1. codeforces Round #347 (Div. 2) C - International Olympiad

    思路:从后往前一位一位的模拟,每次判断一下当前枚举的数是否之间枚举过了.或者当前枚举数过小,小于1989. #include<cstdio> #include<cstring> ...

  2. Codeforces Round #327 (Div. 2) C. Median Smoothing 找规律

    C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/p ...

  3. DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad

    题目传送门 /* DFS: 排序后一个一个出发往后找,找到>r为止,比赛写了return : */ #include <cstdio> #include <iostream&g ...

  4. Codeforces Round #347 (Div. 2)

    unrating的一场CF A - Complicated GCD #include <bits/stdc++.h> const int N = 1e5 + 5; char a[105], ...

  5. Codeforces Round #306 (Div. 2) B. Preparing Olympiad dfs

    B. Preparing Olympiad Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550 ...

  6. Codeforces Round #347 (Div. 2) B. Rebus

    题目链接: http://codeforces.com/contest/664/problem/B 题意: 给你一个等式,把等式左边的问号用1到n(n为等式右边的数)的数填好,使得等式成立 题解: 贪 ...

  7. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises)

    A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足 ...

  8. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) D. Jury Meeting(双指针模拟)

    D. Jury Meeting time limit per test 1 second memory limit per test 512 megabytes input standard inpu ...

  9. Codeforces Round #347 (Div.2)_B. Rebus

    题目链接:http://codeforces.com/contest/664/problem/B B. Rebus time limit per test 1 second memory limit ...

随机推荐

  1. Java关键字介绍之this与super

    1.什么是super?什么是this? super关键字表示超(父)类的意思.this变量代表对象本身. 2.使用super&this调用成员变量和方法 可以使用super访问父类被子类隐藏的 ...

  2. MVC 上传图片的解决方案

    为了避免冲突,分两步来引用nuget第一步为项目安装nuget: Install-Package Backload Install-Package jQuery.FileUpload 分别引用,安装后 ...

  3. 【转载】#323 - A Generic Class is a Template for a Class

    A generic classs is a class that takes one or more type parameters, which it then uses in the defini ...

  4. MATLAB importdata函数返回值类型

    importdata函数是MATLAB中I/O文件操作的一个重要函数.需要注意的是,针对不同的文件内容,importdata函数的返回值类型也有所不同. MATLAB帮助文档中的详细说明如下: Bas ...

  5. WCF之可靠性

    可靠性会话: 端到端(多个点到点系统组成)的可靠性,基于消息,基于WS-*,可以跨平台. 在信道层创建可靠性会话,由两端的缓冲区进行可靠性管理(对消息进行排序后才发给服务器端,接收到消息后回发ACK. ...

  6. 10款让人惊叹的HTML5/jQuery图片动画特效

    1.HTML5相册照片浏览器 可连接Flickr照片服务 以前我们经常会分享一些jQuery相册浏览插件,效果不错,实用性也很强.不过如果能利用HTML5来实现相册浏览器,那么相册浏览效果肯定会更加炫 ...

  7. hibernate 一对多映射关系

    1.   单项多对一映射       custom(顾客)与order(订单) :一个顾客可以有多个订单,一个订单只能有一个顾客       配置方法:在多的一端配置<many -to one& ...

  8. Geodatabase介绍

    一.概述 (1)Geodatabase是什么? ArcGIS操作基于GIS文件格式和存储于地理数据库(Geodatabase)中的地理信息.Geodatabase是ArcGIS的本地数据结构,是用于编 ...

  9. Use XSLT in wix

    Following content is directly reprinted from https://installpac.wordpress.com/2012/05/07/conflict-ma ...

  10. iOS Foundation框架简介 -1.常用结构体的用法和输出

    1.安装Xcode工具后会自带开发中常用的框架,存放的地址路径是: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.plat ...