当前位置:网站首页>Acwing game 57
Acwing game 57
2022-06-30 17:17:00 【Changersh】
4485. Than the size
Given a length of n Array of a1,a2,…,an And a length of n Array of b1,b2,…,bn.
Please calculate , Array a Whether the sum of all elements of the array is greater than or equal to the array b The sum of all the elements of .
Input format
The first line contains integers n.
The second line contains n It's an integer a1,a2,…,an.
The third line contains n It's an integer b1,b2,…,bn.
Output format
If the array a The sum of all elements of is greater than or equal to the array b The sum of all the elements of , The output Yes, Otherwise output No.
Data range
The first three test points meet 1≤n≤5.
All test points meet 1≤n≤50,0≤ai,bi≤1000.
sample input 1:
5
1 2 3 4 5
2 1 4 3 5
sample output 1:
Yes
sample input 2:
5
1 1 1 1 1
1 0 1 0 1
sample output 2:
Yes
sample input 3:
3
2 3 9
1 7 9
sample output 3:
No
Sign in
// Author: Changersh
// Problem: Than the size
// Contest: AcWing
// URL: https://www.acwing.com/problem/content/4488/
// When: 2022-06-29 14:28:38
//
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include<tr1/unordered_map>
#include <tr1/unordered_set>
using namespace std::tr1;
using namespace std;
typedef long long ll;
const int N = 5e4 + 50;
const int MOD = 1e9 + 7;
int n, a, b, sum1, sum2;
int main() {
// scanf("%d", &T);while (T--)solve();
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a);
sum1 += a;
}
for (int i = 0; i < n; i++) {
scanf("%d", &b);
sum2 += b;
}
if (sum1 >= sum2)printf("Yes\n");
else printf("No\n");
return 0;
}
4486. Digital operation
Given an integer n, You can do this number any number of times ( It can be 0 Time ) Change operation .
Each operation is one of the following two :
The integer n Multiply by any positive integer x.
The integer n Replace with n√( The precondition for this operation is n√ Integers ).
Please calculate , By doing this ,n The lowest possible value that can be reached , And the minimum number of operations required to reach the minimum possible value .
Input format
An integer n.
Output format
a line , Two integers , Respectively n The lowest possible value that can be reached , And the minimum number of operations required to reach the minimum possible value .
Data range
All test points meet 1≤n≤106.
sample input 1:
20
sample output 1:
10 2
sample input 2:
5184
sample output 2:
6 4
number theory Decomposing the prime factor
Prime factorization theorem : A number can be decomposed into its prime factors / The product of the same power
Two kinds of operations , One is multiplied by a number x, This does not change the number of types of qualitative factors
The second is to open the square , In fact, the number of times of each prime factor is divided by two , It will not change the number of types of qualitative factors
So the smallest possible value is The product of all prime factors .
Take a 2m, More than all times , Because operation two , The root opening sign is actually the number of all prime factors divided by two .
And multiply at every step you need to multiply x In fact, it is equal to multiplying a total at the beginning x , This is a small number of steps , So put it in the first step 
Actually, the number of times is m Value , Because you have to write a double root , open m Time .
Find the prime factor by trial division , Remember to divide all the prime factors , Calculate the index of the current quality factor ,2m>= The largest index .
after , If n>1, explain n It is its own qualitative factor , The index is 1 .
The previous content means that all quality factor indexes are the same by default , But generally it is different , As long as there is a prime factor less than 2m, On behalf of this n Smaller than what we constructed N, So you need to multiply by a total X, They count + 1,m++
// Author: Changersh
// Problem: Digital operation
// Contest: AcWing
// URL: https://www.acwing.com/problem/content/4489/
// When: 2022-06-29 14:58:27
//
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <vector>
using namespace std::tr1;
using namespace std;
typedef long long ll;
const int N = 5e4 + 50;
const int MOD = 1e9 + 7;
// Decomposing the prime factor
int main() {
int n;
scanf("%d", &n);
vector<int> s; // The number of existential factors
int res = 1;
int m = 0; // The maximum number of times should be less than or equal to 2 Integer power of
// Try to divide into prime factors
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int c = 0; // frequency
while (n % i == 0) n /= i, c++;
res *= i; // result
s.push_back(c);
while (1 << m < c) m++;
}
}
if (n > 1) {
// explain n Prime number
res *= n;
s.push_back(1);
while (1 << m < 1) m++;
}
for (auto x : s) {
if (x < 1 << m) {
m++;
break;
}
}
printf("%d %d", res, m);
return 0;
}
边栏推荐
- Exception class_ Log frame
- Geo read single cell CSV expression matrix single cell column name change Seurat
- MySQL advanced notes
- 期未课程设计:基于SSM的产品销售管理系统
- Cesium-1.72 learning (earth rotation)
- [C language] explain threads - thread separation function pthread_ detach
- nichenet实战silicosis
- Supplementary
- svg实现的订票UI效果
- Eight basic sorting (detailed explanation)
猜你喜欢

Splitting.js文本标题缓慢加载js特效

List announced - outstanding intellectual property service team in China in 2021
![[wechat applet] the hosting environment of the applet](/img/ee/0f1dee4a26eb62c2268484c1b59edf.png)
[wechat applet] the hosting environment of the applet

Compile - compile for itop4412 development board makefile

redis数据结构分析

Property or method “approval1“ is not defined on the instance but referenced during render

TCP socket and TCP connection

24: Chapter 3: develop pass service: 7: user defined exceptions (to represent errors in the program); Create graceexceptionhandler to handle exceptions globally and uniformly (build JSON data of corre

平面相交与平面方程

浅析搭建高速公路视频监控平台的建设方案及必要性
随机推荐
列表变成向量 列表变向量 list vector
《网络是怎么样连接的》读书笔记 - 汇总篇
leetcode:1042. 不邻接植花【随机填入符合要求的 + 后面不会形成矛盾 + set.pop】
STL tutorial 7-set, pair pair pair group and functor
flutter自定义组件
differential analysis between different groups nichenet for silicosis成功运行!
Php7.3 centos7.9 installing sqlserver extensions
开发那些事儿:Linux系统中如何安装离线版本MySQL?
geo 读取单细胞csv表达矩阵 单细胞 改列名 seurat
每日刷题记录 (九)
TCP socket and TCP connection
知名互联网房屋租赁服务公司物联网关键业务迁移上云实践
[JVM] takes you to learn about the garbage collection mechanism (GC) in the JVM -- including diagrams
5G业务正式商用,属于广电的机会在哪?
ROC-RK3566-PC使用10.1寸IPS触摸屏显示
MySQL advanced notes
Consolidate entry-C basic variables and constants
parker比例溢流阀RS10R35S4SN1JW
Jspreadsheet/ce JExcel: more data fields than the given fields (columns) will lead to blank columns. Solution
More than 20million videos have been played in the business list! Why is the reform of Agricultural Academies urged repeatedly?