题意:给定 n 个数,问你从有多少下标 i < j,并且 ai + aj 是2的倍数. 析:方法一: 从输入开始暴力,因为 i < j 和 i > j 是一样,所以可以从前面就开始查找,然后计数,用个map就搞定,不过时间有点长,接近两秒. 方法二: 先排序,然后暴力,暴力的原则是找前面的,也是用map查找,时间62ms. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #inc…
B. Powers of Two You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2 (i. e. some integer xexists so that ai + aj = 2x). Input The first line contains the single positive integer n …
题目链接: B. Powers of Two time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of…
题目链接: 传送门 Devu and Partitioning of the Array time limit per test:3 second memory limit per test:256 megabytes Description You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2 (i.…
Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hacking skills to the test! You've been called upon to help crack enemy codes in the current war on... something or another. Anyway, the point is that yo…
A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Description King Triton really likes watching sport competitions on TV. But much more Triton likes watching live competitions. So Triton decides to set up…
G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G Description After landing on planet i1c5l people noticed that blue and black clothes are quite popular among the locals. Each aboriginal has at least…
D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andr…
题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya's telephone contains n photos. Photo number 1 is currently opened on…
Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers. He has created a m…
D. Diverse Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output 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 ('…
Levels and Regions 把dp方程列出来, 把所有东西拆成前缀的形式, 就能看出可以斜率优化啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int&…
D1. Magic Powder - 1 time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output This problem is given in two versions that differ only by constraints. If you can solve this problem in large constr…