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

 #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<malloc.h>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
#define LL long long
const double eps = 1e-;
const double pi = acos(-);
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// } int vis[];
int a[]={,,,,,,,,,};//看成基数数组
int main(){
int T;
scanf("%d",&T);
char s[];
while(T--){
scanf("%s",s);
int len = strlen(s);
int bas=s[len-]-'';
int extra=;
int index=;
int total=;
int cur;
for(int i=len-;s[i]>=''&&s[i]<='';i--){
extra+=(s[i]-'')*index;
index*=;
int pre=a[bas]/index-;
bool flag=true;
while(flag){
pre++;
cur=pre*index+extra;
if(cur<a[bas]){
continue;
}
flag=false;
for(int j=;j<total;j++){
if(vis[j]==cur){
flag=true;
break;
}
}
}
vis[total++]=cur;
}
printf("%d\n",vis[--total]);
}
return ;
}

codeforces Round #347 (Div. 2) C - International Olympiad的更多相关文章

  1. Codeforces Round #347 (Div. 2) C. International Olympiad 找规律

    题目链接: http://codeforces.com/contest/664/problem/C 题解: 这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99- ...

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

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

  3. Codeforces Round #347 (Div. 2)

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

  4. 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 ...

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

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

  6. 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不可约分,如果存在多组满足 ...

  7. 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 ...

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

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

  9. Codeforces Round #347 (Div.2)_A. Complicated GCD

    题目链接:http://codeforces.com/contest/664/problem/A A. Complicated GCD time limit per test 1 second mem ...

随机推荐

  1. Javascript代码摘录

    判断浏览器窗口高度 if (document.documentElement.clientHeight <800) { var elm = document.getElementById('Di ...

  2. eclipse:java.lang.OutOfMemoryError: PermGen space 最简单的解决方式

    我使用的工具是STS, Eclipse同理: 打开如下界面: 左则选择项目启动使用的Tomcat-->在右侧面板Tab项中选择" Arguments":在VM argumen ...

  3. C Primer Plus(第五版)学习笔记-可变宏:...和__VA_ARGS__

    一 .__VA_ARGS__ P454 所讲printf()这些输出函数的参数是可变的,在调试程序时,可能希望定义参数为可变的输出函数, 那么可变参数宏会是一个选择,例如: #define DEBUG ...

  4. 2014年辛星完全解读Javascript第二节

    本小节我们讲解一下Javascript的语法,虽然js语言非常简单,它的语法也相对好学一些,但是不学总之还是不会的,因此,我们来一探究竟把. ********注释************* 1.我们通 ...

  5. 2014年度辛星css教程夏季版第四节

    接下来的这一节我计划讲解的是超链接和列表的样式,然后我们做出一个导航栏出来,其实导航栏是非常常见的,但是我们这里做得这个有点并不那么完善,等我们学完了css之后再完善它. ************** ...

  6. pywinauto简单介绍

    Pywinauto是基于Python开发的,用于自动化测试的脚本模块,主要操作于Windows标准图形界面.它可以允许你很容易的发送鼠标.键盘动作给Windows的对话框和控件. 其中,最主要功能为对 ...

  7. linux环境下验证码不显示的几种情况

    linux环境下验证码不显示的几种情况 gd库扩展没有安装. 查看phpinfo(),看看有没有安装gd库 yum安装gd库或者phpize安装 安装完成后记得重启php-fpm bom头的原因 在生 ...

  8. 使用自定义 URL 实现控制器之间的跳转-b

    一个app往往有很多界面,而界面之间的跳转也就是对应控制器的跳转,控制器的跳转一般有两种情况 push 或者 modal,push 和 modal 的默认效果是系统提供的 文章配图 1. 概述 系统提 ...

  9. Hadoop 2.4.0完全分布式平台搭建、配置、安装

    一:系统安装与配置 Hadoop选择下载2.4.0 http://hadoop.apache.org / http://mirror.bit.edu.cn/apache/hadoop/common/h ...

  10. textarea中的文字自动换行问题

    在textarea中设置输入内容的自动换行,也是在CSS中设置word-wrap:break-word; 属性.需要额外注意的是textarea元素本身有一个warp属性,其取值含义如下: off:不 ...