Українська
Відкрити в Telegram

Постimport java.util.*;

19 квітня 2025
D
Deloitte | COGNIZANT | IBM | CAPGEMINI
import java.util.*; public class Main { public static long solve(int n, int[] wealth) { int maxWealth = 0; for (int val : wealth) { maxWealth = Math.max(maxWealth, val); } int maxPossibleSum = 2 * maxWealth; Set<Long> uniquePowers= new HashSet<>(); long p = 1; while (p <= maxPossibleSum) { uniquePowers.add(p); p *= 3; } Map<Integer, Integer> freq = new HashMap<>(); for (int w : wealth) { freq.put(w, freq.getOrDefault(w, 0) + 1); } long count = 0; for (int a : freq.keySet()) { for (long x : uniquePowers) { long b = x - a; if (b < 0 || b > Integer.MAX_VALUE) continue; if (freq.containsKey((int)b)) { if (a < b) { count += (long) freq.get(a) * freq.get((int)b); } else if (a == b) { count += (long) freq.get(a) * (freq.get(a) - 1) / 2; } } } } return count; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] wealth = new int[n]; for (int i = 0; i < n; i++) { wealth[i] = sc.nextInt(); } System.out.println(solve(n, wealth)); } } valid pairs✅✅ #zl_technologies
1K ·

Поруч у стрічці

DDeloitte | COGNIZANT | IBM | CAPGEMINICTS COMMUNICATION✅✅ contact : @MLCODER2DDeloitte | COGNIZANT | IBM | CAPGEMINIGot selected for IBM 🥳🥳✅✅✅ 100% results for any interview and exam ✅ IBM offline coding help👇 https://t.me/python_java_Coding/8426 Contact: @MLCODER2
це повідомлення
DDeloitte | COGNIZANT | IBM | CAPGEMINISELECT product_name FROM products WHERE price <= 5 ORDER BY price DESC, product_name ASC; SQL✅ #zl_technologiesDDeloitte | COGNIZANT | IBM | CAPGEMINICTS 9AM Aptitude ✅✅✅ Contact : @MLCODER2

Відкрита публічна стрічка з пошукового індексу ChatCrawler — «Google по публічному Telegram»; оновлюється в міру обходу майданчика. Час — UTC.

Лише публічний контент, офіційний API Telegram. Про проєкт · Питання · Межі індексу · Прибрати сторінку з видачі · Каталог · Пошук · Як ми рахуємо