题目链接: 传送门 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.…
题意:给定 n 个数,问你从有多少下标 i < j,并且 ai + aj 是2的倍数. 析:方法一: 从输入开始暴力,因为 i < j 和 i > j 是一样,所以可以从前面就开始查找,然后计数,用个map就搞定,不过时间有点长,接近两秒. 方法二: 先排序,然后暴力,暴力的原则是找前面的,也是用map查找,时间62ms. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #inc…
A positive integer xx is called a power of two if it can be represented as x=2y, where y is a non-negative integer. So, the powers of two are 1,2,4,8,16,… You are given two positive integers nn and k. Your task is to represent nn as the sumof exactly…
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 …
题目连接:http://codeforces.com/problemset/problem/1095/C 题目: C. Powers Of Two time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output A positive integer xx is called a power of two if it can be repres…
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 x exists so that ai + aj = 2x). Input The first line contains the single positive integer n (1 ≤ n ≤ 105) — th…
A. Strange Addition time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digi…
A. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and un…