Codeforces Round #320 DIV.2

分析:细菌每次一天一分为二,给定希望看到的细菌个数,求需要放多少个细菌。1,2,4,8,16.......细菌个数每天加倍增长。

#include
using namespace std;
int main()
{
   int x;
    cin>>x;
   int flag=1;
   while(x>1){
        if(x%2==1)flag++; //如果x是奇数,就需要放一个细菌来补齐,
        x=x>>1; //求前一天细菌个数,直到x=1,第一天的
    }
    cout<

分析:因为需要两个人的力量最强,所以需要从大到小排列每个力量值,然后依次保存这个力量值是那两个人组合形成的,如果两个人都没和别人搭档,就保存,否则,看下一组。

#include
#include
#include
#include
#include
using namespace std;
typedef struct p
{
    int x,y,v;
};

bool cmp(p aa,p bb){
    return aa.v>bb.v;
}
p a[320000];
int q[805];
bool used[805];
int main()
{
    int n;
    int k;
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    int num=0;
    for(int i=2;i<=2*n;i++){
        for(int j=1;j

纯数学问题:可以转化为斜率已知的两条直线,一个是-1,一个是1,然后给你一个点,问,是否可以有上边两条直线经过?这个很简单,推倒一下公式就好了。

#include 
typedef long long LL;
using namespace std;
int main(){
    LL a,b;
    cin>>a>>b;
    if(a

分析:如果想获得最大的值,x>=2,每一次乘以x,向前至少进以为,所以k次x是不能分开乘的,至于乘以那个数最大,那么枚举都计算一遍,找到最大的就行了

#include
#define LL long long
using namespace std;
const int maxn=200005;
int a[maxn];
LL nextt[maxn],last[maxn];
int main()
{
  //  freopen("f.txt","r",stdin);
    LL n,k,x,t,temp,xx=1;
    cin>>n>>k>>x;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    while(k--)
        xx*=x;
    LL ans=0;
    nextt[0]=last[n+1]=0;
    for(int i=1;i<=n;i++)
       nextt[i]=nextt[i-1]|a[i];
    for(int i=n;i>0;i--)
        last[i]=last[i+1]|a[i];
    for(int i=1;i<=n;i++){
       ans=max(ans,nextt[i-1]|(xx*a[i])|last[i+1]);
    }
    cout<



你可能感兴趣的:(Codeforces)