Codeforces 672
题目链接:http://codeforces.com/contest/672/problem
A. Summer Camp(打表)
题意:123456789...一串字符串,问第n个是什么数字。
塞一个表进去。
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Fuint(a) memset((a), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long Uint;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; int n;
string t = "";
int main() {
// FRead();
while(~Rint(n)) {
printf("%d\n", t[n]-'');
}
RT ;
}
A
B. Different is Good(构造,胡搞)
题意:给一个数字n和一个字符串s,s中含有n个不同的字符,要求出现的所有字串的子串都不同,问最少修改字符串中多少个字符。
显然长度为1的子串想不同的话,必须每个字符都不同。所以当n>26的时候不可行;统计所有字符出现次数-1就是需要修改的字符数,修改次数超过26也是不允许的。
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Fuint(a) memset((a), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long Uint;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
int n;
char s[maxn];
int vis[]; int main(int argc, char const *argv[]) {
// FRead();
while(~Rint(n)) {
Cls(vis);
Rs(s);
if(n > ) {
printf("-1\n");
continue;
}
for(int i = ; s[i]; i++) {
vis[s[i]]++;
}
int ret = ;
Rep(i, ) {
if(vis[i] > ) ret += vis[i] - ;
}
if(ret > ) printf("-1\n");
else printf("%d\n", ret);
}
return ;
}
B
Codeforces 672的更多相关文章
- codeforces 672 D
题目链接:http://codeforces.com/problemset/problem/672/D 题目大意:进行k次操作,每次将最大值集合中最大值-1,最小值+1,问你K次操作之后,最大值和最小 ...
- Codeforces Round #672 (Div. 2) A - C1题解
[Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more th ...
- Codeforces Round #672 (Div. 2) D. Rescue Nibel!(排序)
题目链接:https://codeforces.com/contest/1420/problem/D 前言 之前写过这场比赛的题解,不过感觉这一题还可以再单独拿出来好好捋一下思路. 题意 给出 $n$ ...
- Codeforces Round #672 (Div. 2)
比赛链接:https://codeforces.com/contest/1420 A. Cubes Sorting 题意 给出一个大小为 $n$ 的数组 $a$,每次只可以交换相邻的两个元素,最多交换 ...
- Codeforces Round #672 (Div. 2) B. Rock and Lever题解(思维+位运算)
题目链接 题目大意 给你一个长为n(n<=1e5)的数组,让你求有多少对a[i]和a[j] (i!=j)满足a[i]&a[j]>a[i]^a[j] 题目思路 这些有关位运算的题目肯 ...
- Codeforces Round #672 (Div. 2) D. Rescue Nibel! (思维,组合数)
题意:给你\(n\)个区间,从这\(n\)区间中选\(k\)个区间出来,要求这\(k\)个区间都要相交.问共有多少种情况. 题解:如果\(k\)个区间都要相交,最左边的区间和最右边的区间必须要相交,即 ...
- Codeforces Round #672 (Div. 2) C1. Pokémon Army (easy version) (DP)
题意:给你一组数\(a\),构造一个它的子序列\(b\),然后再求\(b_1-b2+b3-b4...\),问构造后的结果最大是多少. 题解:线性DP.我们用\(dp1[i]\)来表示在\(i\)位置, ...
- Codeforces Round #672 (Div. 2 B. Rock and Lever (位运算)
题意:给你一组数,求有多少对\((i,j)\),使得\(a_{i}\)&\(a_{j}\ge a_{i}\ xor\ a_{j}\). 题解:对于任意两个数的二进制来说,他们的最高位要么相同要 ...
- Codeforces Round #672 (Div. 2) A. Cubes Sorting (思维)
题意:有一长度为\(n\)的一组数,每次可以交换两个数的位置,问能否在\(\frac{n*(n-1)}{2}-1\)次操作内使得数组非递减. 题解:不难发现,只有当整个数组严格递减的时候,操作次数是\ ...
随机推荐
- 利用QObject反射实现jsonrpc
1.jsonrpc请求中的params数组生成签名 static QString signatureFromJsonArray(const QJsonArray &array) { QStri ...
- SpringMVC+redis整合
在网络上有一个很多人转载的springmvc+redis整合的案例,不过一直不完整,也是被各种人装来转去,现在基本将该框架搭建起来. package com.pudp.bae.base; import ...
- usb口外接了Com设备,U盘识别不了问题
就如本题,当我usb口外接了Com设备时候,再插入U盘会出现识别不了的问题. 解决方法非常的简单,只要拨出这个com设备的usb就可以使用U盘了^_^
- res/drawable目录下图片的Uri
http://liuyun025.iteye.com/blog/1280838 有时候,我们要用到res/drawable目录下的图片Uri,而这个Uri该如何生存呢?下面就是这Uri的生成方法: U ...
- 2186: [Sdoi2008]沙拉公主的困惑 - BZOJ
Description 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行编号与M!互质的钞票.房地产第一大户沙拉公主决定预测一下大富翁国现 ...
- 3139:[HNOI2013]比赛 - BZOJ
题目描述 Description 沫沫非常喜欢看足球赛,但因为沉迷于射箭游戏,错过了最近的一次足球联赛.此次联赛共N只队伍参加,比赛规则如下: (1) 每两支球队之间踢一场比赛. (2) 若平局,两支 ...
- [spring]启动时报错:NoSuchMethodError: javax.servlet.http.HttpServletResponse.getStatus()I
Spring V4.1以后的版本在不支持Servlet3.0的应用服务器上跑时会报如下错误: NoSuchMethodError: javax.servlet.http.HttpServletResp ...
- JavaScript高级---桥模式设计
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- PHP对XML文件操作类讲解
<?phpclass XML{ private $dom; function __construct () { $this->dom = new D ...
- Unity3d 模型导入选项