春之电-3总结
Div.2
T1:
| 编号 | 结果 |
|---|---|
| 1 |
思路:
首先观察等级排序,发现这玩意最大的特点是
MYCODE:
#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
#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的可乘数为1