codeforces Nikita and string time limit per test 2 seconds memory limit per test 256 megabytes One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 stri…
题目描述 Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, managed to get hold of th…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to…
Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just de…
Nirvana 题目链接(点击) Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper. Help Kurt find the maximum possible product of digits among all integers from 11 to nn.…
题目链接:传送门 A. Elections (思维+暴力) 思路: 从最小的k开始枚举就好了- -. #include <bits/stdc++.h> using namespace std; + ; int a[MAX_N]; int main() { int N; cin >> N; , sum = ; ; i <= N; i++) { scanf("%d", a+i); m = max(m, a[i]); sum += a[i]; } int a…
第二章 如何实现应用RSA算法 趁着白天在自家店里的闲暇时间来写写第二章了,假设记住了第一章的各种定理之后,我们又该如何实现RSA密码的加密解密呢?也懒得废话了,直接进入正题吧. 先回顾几个知识点: 1.模运算的性质: 结合律:(a % p * b) % p = (a * b) % p 可知当a == b时,(a % p * a) % p = (a * a) % p 2.欧拉定理 a^φ(n) ≡ 1 (mod n) 3.乘法逆元性质 e * d ≡ 1 (mod n) => e * d ≡ 1…
题目链接:http://agc015.contest.atcoder.jp/tasks/agc015_d 题意:给出两个数b,a(a>=b)问{a,a+1,....,b}的集合内取任意数求或运算最多能够表示多少个数. 题解:数据很吧不用想着暴力,主要是位运算一般都会想到用二进制来写.具体的写法详见代码注释,不好表达. #include <iostream> #include <cstring> using namespace std; typedef long long ll…
AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都错.....暴力都不会了,,,,, #include<iostream> #include<vector> #include<limits> #include<algorithm> using namespace std; typedef long long l…
AtCoder Grand Contest 019 B - Reverse and Compare 题意:给定字符串,可以选定任意i.j且i<=j(当然i==j时没啥卵用),然后翻转i到j的字符串,问能组成多少种不同的字符串. tourist出的题..感觉好棒,虽然简单,但我就是不知道怎么弄,感觉思维好匮乏. 首先,如果Si=Sj,那么反转i到j和翻转i+1到j-1是一样的,也就是这种翻转不会贡献更多的答案.那么其实只要求i<j且Si!=Sj的个数就行了,当然,本身不变也是一种答案.求解i&l…