当前位置:网站首页>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;
}
边栏推荐
- Cesium-1.72 learning (model attitude control)
- Data security compliance has brought new problems to the risk control team
- Exercise book of introduction to database system
- Etcd tutorial - Chapter 9 etcd implementation of distributed locks
- [demo] write file circularly
- MySQL8 NDB Cluster安装部署
- differential analysis between different groups nichenet for silicosis成功运行!
- Jsr303 and common validator implementations
- idea必用插件
- 补充材料 supplementary
猜你喜欢
leetcode:1042. 不邻接植花【随机填入符合要求的 + 后面不会形成矛盾 + set.pop】
Jsr303 and common validator implementations
k线图精解与实战应用技巧(见位进场)
The meaning of linetypes enumeration values (line_4, line_8, line_aa) in opencv
Redis data structure analysis
Mysql8 NDB cluster installation and deployment
Redis elimination strategy
巩固入门-C#基础变量和常量
基于51单片机的计件器设计
数据安全合规之后,给风控团队带来了新的问题
随机推荐
数据库系统概论习题册
商鼎云新版来袭 | 收藏夹功能已上线,满足个人使用需求
Parler du télétravail
MySQL advanced notes
SSH tool pyqt
阿里云盘分享压缩包
数据中心的能耗焦虑, 到底有没有最优解?
js 从原型链到继承
互联网研发效能实践之去哪儿网(Qunar)核心领域DevOps落地实践
HMS core audio editing service 3D audio technology helps create an immersive auditory feast
Jsr303 and common validator implementations
以往我们认识的产业互联网,只是以消费互联网的替代者的身份出现
解决方法:STM32使用cJSON解析数据失败
AcWing 第 57 场周赛
数据分析新动力——国内首款开源一体化实时HTAP数据库石原子StoneDB发布
面试突击60:什么情况会导致 MySQL 索引失效?
Servlet运行原理_API详解_请求响应构造进阶之路(Servlet_2)
[C language] detailed explanation of threads - multi threads for collaborative operation
基于51单片机的计件器设计
3D图表有效提升数据大屏档次