a2 now let ai=a1 and aj=a2 x the divisor a1 ==>let say a1=a1/x and aj=aj*x; ==>now a1/x=a2*x now multiply these two we get (a1/x)*(aj*x)=a1*a2; we can generalise after all the operation when we multiply all the elements we get a1*a2*a3*a4... so we can general...
here we have to choose two element in the array let ai,aj and choose a divisor of ai let x and replace ai=ai/x ans aj=aj*x; after some operation we have to make all the element equal in that array now let consider an array of two elements a1,a2 now let ai=a1 and aj=a2 x ...
1881D-DivideAndEqualize.cpp 1882A-IncreasingSequence.cpp 1882B-SetsAndUnion.cpp 1883A-Morning.cpp 1883B-Chemistry.cpp 1883C-Raspberries.cpp 1884A-SimpleDesign.cpp 1884B-HauntedHouse.cpp 1886A-SumOfThree.cpp 1886B-FearOfTheDark.cpp 1890A-DoremysPaint3.cpp 1890B-QingshanLovesStrings.cpp 1891A-...
D. Divide and Equalize(简单数论) 给定一个数组 每次可以选择2个不同小标ai,aj, 找ai的因数x,令ai=ai/x,aj=aj*x 执行上述操作任意次,问,能否让所有元素相等。 思路:求所有素数,看它们的幂次是否能整除n voidsolve(){cin>>n;map<int,int>mp;for(inti=0;i<n;++i){cin>>x;m=sqrt(x);for(int...
思路:直接暴力,注意不要超限,会MLE // AC one more times // nndbk #include<bits/stdc++.h> using namespacestd; typedeflonglongll; constintmod =1e9+7; constintN =2e5+10; intns[30],nt[30]; intmain() { ios::sync_with_stdio(false);cin.tie(nullptr),cout.tie(nullptr); ...
1797A-LiHuaAndMaze.cpp 1797B-LiHuaAndPattern.cpp 1798A-Showstopper.cpp 1798B-ThreeSevens.cpp 1799A-RecentActions.cpp 1799B-EqualizeByDivide.cpp 1800A-IsItACat.cpp 1800B-CountTheNumberOfPairs.cpp 1800C1-PoweringTheHeroEasyVersion.cpp 1800C2-PoweringTheHeroHardVersion.cpp 1800D-RemoveTwoLetters.cp...
D. Divide and Equalize # 题目大意: 给出一个长度为n的数组a,每次操作可以选择一对i,j,使得 a_i 变为\frac{a_i}{x}, a_j 变为a_j *x(x为 a_i 的因数),可以执行任意次操作,问能使得数组中所有元素相等。 # 解题思路: 对于a中所有元素分解质因数,记录下每个因数出现的次数,判断每个因数出现的...
C. Insert and Equalize D. Robot Queries E. Collapsing Strings F. Trees and XOR Queries Again Educational Codeforces Round 158 (Rated for Div. 2) A. Line Trip B. Chip and Ribbon C. Add, Divide and Floor D. Yet Another Monster Fight E. Compressed Tree F. Landscaping Educational Codeforces...
D. Divide and Equalize int solve(){ int n; cin>>n; vector v(n); input_arr(v); unsigned int x=1; sort(v.begin(),v.end()); for (int i = 0; i < v.size(); i++) { x*=v[i];} if(x==1 || v[0]==v[n-1]){ cout<<"YES\n"; return 1; } int y=1; int ...
1454 A - Turtle and Good Strings C++17 (GCC 7-32) greedy strings *800 Aug/25/2024 20:37 1453 C - Guess The Tree C++17 (GCC 7-32) binary search brute force dfs and similar divide and conquer dsu greedy interactive trees *1500 Aug/20/2024 22:23 1452 B - Generate Permutation C++17...