A Divide it!
#include
using namespace std;
#define ll long long
int main()
{
int t;
scanf("%d",&t);
ll x;
while(t--){
scanf("%I64d",&x);
ll ans=0;
while(x>1&&x%2==0){
x/=2;
ans++;
}
while(x>1&&x%3==0){
x/=3;
ans+=2;
}
while(x>1&&x%5==0){
x/=5;
ans+=3;
}
if(x>1)
printf("-1\n");
else
printf("%I64d\n",ans);
}
return 0;
}
B Merge it!
#include
using namespace std;
#define ll long long
int main()
{
int t,n,x;
scanf("%d",&t);
while(t--){
int n,a=0,b=0,ans=0;
scanf("%d",&n);
while(n--){
scanf("%d",&x);
if(x%3==0) ans++;
else if(x%3==1) a++;
else b++;
}
if(a>b){
ans+=b;
a-=b;
ans+=a/3;
}else{
ans+=a;
b-=a;
ans+=b/3;
}
printf("%d\n",ans);
}
return 0;
}
C Lose it!
题意:求删去最少元素,使得数组可以由多个或一个子序列{4,8,15,16,23,42}组成,子序列可以不连续 题解:2019广东省省赛复现,对于当前元素cur,如果它前一个pre不存在,说明这个元素必删,否则mp[cur]++,mp[pre]–。
#include
using namespace std;
#define ll long long
int a[8]={4,8,15,16,23,42};
int pre[50];
int mp[50];
int main()
{
int t,n,x;
pre[8]=4;
pre[15]=8;
pre[16]=15;
pre[23]=16;
pre[42]=23;
while(~scanf("%d",&n)){
int ans=0;
memset(mp,0,sizeof(mp));
for(int i=0;i mx[ai]
*/
int mx[maxn],Prime[maxn];//2750131
void init()
{
for(int i=1;i
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?