codeforces Round #347 (Div. 2) C - International Olympiad
思路:从后往前一位一位的模拟,每次判断一下当前枚举的数是否之间枚举过了。或者当前枚举数过小,小于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的更多相关文章
- Codeforces Round #347 (Div. 2) C. International Olympiad 找规律
题目链接: http://codeforces.com/contest/664/problem/C 题解: 这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99- ...
- DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad
题目传送门 /* DFS: 排序后一个一个出发往后找,找到>r为止,比赛写了return : */ #include <cstdio> #include <iostream&g ...
- Codeforces Round #347 (Div. 2)
unrating的一场CF A - Complicated GCD #include <bits/stdc++.h> const int N = 1e5 + 5; char a[105], ...
- 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 ...
- Codeforces Round #347 (Div. 2) B. Rebus
题目链接: http://codeforces.com/contest/664/problem/B 题意: 给你一个等式,把等式左边的问号用1到n(n为等式右边的数)的数填好,使得等式成立 题解: 贪 ...
- 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不可约分,如果存在多组满足 ...
- 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 ...
- Codeforces Round #347 (Div.2)_B. Rebus
题目链接:http://codeforces.com/contest/664/problem/B B. Rebus time limit per test 1 second memory limit ...
- 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 ...
随机推荐
- 阿里云服务器centos5.10安装lamp环境
==相关命令== 查看linux版本:cat /etc/redhat-release ==配置修改== 一.Apache配置 ------------------------------------- ...
- centos不能挂在ntfs
root@s 下载]# mount /dev/sdb1 /mnt mount: unknown filesystem type 'ntfs' wget http://www.tuxera.com/co ...
- SQL的多表操作
多表更新: 假定我们有两张表,一张表为Product表存放产品信息,其中有产品价格列Price:另外一张表是ProductPrice表,我们要将ProductPrice表中的价格字段Price更新为P ...
- 常用 xwt 工具
1,显示提示信息 <FString chnName="执行单位" prompt="可以进行模糊匹配" required="false" ...
- Class.forName()的作用与使用总结(转载)
转载自:Class.forName()的作用与使用总结 1.Class类简介: Java程序在运行时,Java运行时系统一直对所有的对象进行所谓的运行时类型标识.这项信息纪录了每个对象所属的类.虚拟机 ...
- Swagger+AutoRest
Swagger+AutoRest 生成web api客户端(.Net) 简介 对于.net来说,用web api来构建服务是一个不错的选择,都是http请求,调用简单,但是如果真的要在程序中调用, ...
- iOS 7隐藏statusbar
- (BOOL)prefersStatusBarHidden { return YES; } [[UIApplication sharedApplication] setStatusBarHidden ...
- Python元类实践--自己定义一个和collections中一样的namedtuple
大家可能很熟悉在collections模块中有一个很好用的扩展数据类型-namedtuple. 如果你还不知道这个类型,那么请翻看标准手册. 我利用元类轻松定义一个namedtuple. 先把代码贴上 ...
- 换一换js
(function(){ var tit = $("#changes"), con = $("#wday>ul"), page = con.length, ...
- StreamCQL
StreamCQLhttps://github.com/HuaweiBigData/StreamCQL http://blog.csdn.net/viewcode/article/details/90 ...