Deutsch
Telegram

Beitragimport java.util.*;

19. April 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 ·

In der Nähe im Feed

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
diese Nachricht
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
DDeloitte | COGNIZANT | IBM | CAPGEMINIDeloitte | COGNIZANT | IBM | CAPGEMINI@python_java_Coding · Kanal · Technik
7 178Abonnenten406durchschnittliche Beitragsreichweite
Community-Feed In Telegram öffnen

Ein offener öffentlicher Feed aus dem Suchindex ChatCrawler — „Google für das öffentliche Telegram“; wird aktualisiert, während die Community gecrawlt wird. Zeiten in UTC.

Nur öffentliche Inhalte, offizielle Telegram-API. Über uns · FAQ · Grenzen des Index · Seite entfernen · Katalog · Suche · So zählen wir