跳到正文

个人记录

春之电-3总结

DEEC_约 2 分钟
原文
文章信息与版本

文章信息

发布
2024年4月6日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 2 分钟

版本

  1. v1当前

Div.2

T1:

编号结果
1100\color{green} 100

思路:

首先观察等级排序,发现这玩意最大的特点是 1>131>13 ,因此可以特判1的情况,其他的直接写判断就行了

MYCODE:

C++
#include<bits/stdc++.h>
using namespace std;
int a,b;
void fre()
{
	freopen("at1.in","r",stdin);
	freopen("at1.out","w",stdout);
}
int main()
{
	//fre();
	cin>>a>>b;
	if(a==1&&b!=1)
	{
		cout<<"Alice";
		return 0;
	}
	else if(b==1&&a!=1)
	{
		cout<<"Bob";
		return 0;
	}
	else if(a>b)
	{
		cout<<"Alice";
		return 0;
	}
	else if(b>a)
	{
		cout<<"Bob";
		return 0;
	}
	if(a==b)
	{
		cout<<"Draw";
		return 0;
	}
}

at2

我的思路: 输入每个数,然后便利每个数,统计他们能够被2出的次数,最后相加

事实上,这玩意会炸

mycode

C++
#include<bits/stdc++.h>
using namespace std;
const int kp[13]=[0,100,1,2,3,4,5,6,7,8,9,10,11,12];
int main()
{
	int n;
	cin>>n;
	int a[n+10];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans=0,num=0;
	for(int i=0;i<n;i++)
	{
		num=0
		while(1)
		{
			if(a[i]%2==0)
			{
				a[i]/=2;
				num++;
			}
		}
		ans+=num;
	}
	cout<<ans;
	return 0;
}

用这个方法会一堆TLE

所以现在有两个方法

方法一:求2的快速幂,用2得快速幂去除

弊端:还是要遍历2的快速幂数组,相当于速度还是没快多少

方法二:分解只因数(solution)

找出里面2的个数

推理;

以182为例: 182=2∗7∗13182 = 2 * 7 * 13 因此182的可乘数为1

原文