当前位置:网站首页>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;
}
边栏推荐
- 《网络是怎么样连接的》读书笔记 - 汇总篇
- leetcode:787. K 站中转内最便宜的航班【k步最短路 + dfs记忆化 + defaultdict(dict)】
- Ningx 1.20.2
- Lambda expression_ Stream stream_ File class
- 9: Chapter 3: e-commerce engineering analysis: 4: [general module]; (to be written...)
- 以往我们认识的产业互联网,只是以消费互联网的替代者的身份出现
- idea必用插件
- 基于SSM实现毕业设计管理系统
- leetcode:1042. 不邻接植花【随机填入符合要求的 + 后面不会形成矛盾 + set.pop】
- Deep learning - (2) several common loss functions
猜你喜欢

商鼎云新版来袭 | 收藏夹功能已上线,满足个人使用需求

Cesium-1.72 learning (China national boundary)

Cesium-1.72 learning (camera tracking)

面试突击60:什么情况会导致 MySQL 索引失效?

登录框Tricks

differential analysis between different groups nichenet for silicosis成功运行!

将 EMQX Cloud 数据通过公网桥接到 AWS IoT

EMQ 助力青岛研博建设智慧水务平台

MySQL8 NDB Cluster安装部署

力士乐液控单向阀Z2S10-1-3X/
随机推荐
Go micro tutorial - Chapter 1 getting started
泰山OFFICE技术讲座:同一行不同字号的字如何对齐绘制
Redis data structure analysis
Parler du télétravail
理解现货白银走势的关键
Nut cloud - sync files on your mobile hard drive on your new computer
期未课程设计:基于SSM的产品销售管理系统
将 EMQX Cloud 数据通过公网桥接到 AWS IoT
数据安全合规之后,给风控团队带来了新的问题
ROC-RK3566-PC使用10.1寸IPS触摸屏显示
面试突击60:什么情况会导致 MySQL 索引失效?
List becomes vector list becomes vector list vector
Etcd tutorial - Chapter 9 etcd implementation of distributed locks
Multi terminal collaboration of Huawei accounts to create a better internet life
【JVM】类加载相关面试题——类加载过程、双亲委派模型
以往我们认识的产业互联网,只是以消费互联网的替代者的身份出现
CGR 21 (D,E,F)
列表变成向量 列表变向量 list vector
Research on helmet wearing detection algorithm
STL tutorial 7-set, pair pair pair group and functor