题目链接:

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. [老老实实学WCF] 第一篇 Hello WCF

    老老实实学WCF  第一篇 Hello WCF WCF(Windows Communication Foundation)是微软公司推出的面向服务技术的集大成者,涵盖继承了其之前发布的所有的分布式应用 ...

  2. Swift数据类型及数据类型转换

    整型  Swift 提供 8.16.32.64 位形式的有符号及无符号整数.这些整数类型遵循 C 语言的命名规 约,如 8 位无符号整数的类型为 UInt8,32 位 有符号整数的类型为 Int32 ...

  3. JavaScript中Array的一些实用操作技巧

    最近在调试JSP页面时频繁与ajax打交道,在复杂场景下,ajax传参数就需要对大量参数进行处理.这时我才发现,熟练Array的处理真的会使开发轻松不少!! 关于Array Array的创建很灵活,可 ...

  4. Linux美化——终端提示符

    1. PS1变量简介[1] PS1是Linux终端用户的一个环境变量,用来说明命令行提示符的设置. 可以使用 man bash命令查看bash手册,找到该变量支持的特殊字符,以及这些特殊字符的意义: ...

  5. Linux ThunderBird Exchange 过期

    在Linux上只用Web版处理邮件,就是因为找不到太好的能支持Exchange的邮件客户端.在网上无意中发现了ExQuilla这个Thunderbird的插件,试用了一下还是不错的,很方便,不过只能免 ...

  6. 14种网页jQuery和css3特效插件代码演示

    1.网页table增删样式代码 演示和下载地址 2.jQuery左右滑动幻灯片插件 演示和下载地址 3.jQuery文字轮播焦点图 演示和下载地址 4.网页文字焦点图切换 演示和下载地址 5.jQue ...

  7. Stanford parser:入门使用

    一.stanford parser是什么? stanford parser是stanford nlp小组提供的一系列工具之一,能够用来完成语法分析任务.支持英文.中文.德文.法文.阿拉伯文等多种语言. ...

  8. UDP HelloWord

    Client.cpp #include <stdio.h> #include <winsock2.h> #pragma comment (lib,"ws2_32&qu ...

  9. Zend-MVC事件

    Zend\Mvc\MvcEvent继承自Zend\EventManager\Event,在Zend\Mvc\Application::bootstrap()执行时触发.如果你的控制器实现了Zend\M ...

  10. Query execution was interrupted, max_statement_time exceeded

    版本:5.6.16 群里看见一个问题,在备份的时候,报如下错误:[root@B28-19-75 bak]# mysqldump -root -p --single-transaction --mast ...