A

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int n,m;
int main()
{
int n,m,i,j;
cin>>n>>m;
if(m>n)
cout<<n<<endl;
else
{
int o = ;
while(n)
{
n--;
o++;
if(o%m==) n++;
}
cout<<o<<endl;
}
return ;
}

B

枚举和值

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
#define M 1000000000
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int o[N];
int judge(LL x)
{
int ans = ;
while(x)
{
ans+=x%;
x/=;
}
return ans;
}
int main()
{
int a,b,c,i,j;
cin>>a>>b>>c;
int g = ;
for(i = ; i <= ; i++)
{
LL k = (LL)b*pow(i*1.0,a)+c;
if(judge(k)==i&&k>&&k<M)
o[++g] = k;
}
cout<<g<<endl;
if(g)
{ sort(o+,o+g+);
for(i = ; i < g ; i ++)
cout<<o[i]<<" ";
cout<<o[i]<<endl;
}
return ;
}

C

二分高度,之后用高度减去原有高度,就可以知道每株花被浇了多少水,用线段树维护一下就可以得到最少浇水的次数。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100010
#define LL long long
#define INF 0xfffffff
#define M 1000200000
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int a[N],o[N];
LL s[N<<];
int n,m,w;
void build(int l,int r,int w)
{
s[w] = ;
if(l==r)
{
s[w] = o[l];
return ;
}
int m = (l+r)>>;
build(l,m,w<<);
build(m+,r,w<<|);
}
void down(int w,int m)
{
if(s[w])
{
s[w<<] += s[w];
s[w<<|] += s[w];
s[w] = ;
}
}
void update(int a,int b,int d,int l,int r,int w)
{
if(a<=l&&b>=r)
{
s[w]+=d;
return ;
}
down(w,r-l+);
int m = (l+r)>>;
if(a<=m) update(a,b,d,l,m,w<<);
if(b>m) update(a,b,d,m+,r,w<<|);
}
LL query(int p,int l,int r,int w)
{
if(l==r)
return s[w];
down(w,r-l+);
int m = (l+r)>>;
if(p<=m) return query(p,l,m,w<<);
else return query(p,m+,r,w<<|);
}
int cal(int k)
{
int i,j;
for(i = ; i <= n; i++)
if(k>a[i]) o[i] = k-a[i];
else o[i] = ;
build(,n,);
LL num = ;
for(i = ; i <= n; i++)
{
int pp = query(i,,n,); if(pp>) {update(i,min(n,i+w-),-pp,,n,);num+=pp;} if(num>m) return ;
}
if(num<=m) return ;
return ;
}
int main()
{
int i,j;
cin>>n>>m>>w;
for(i = ; i <= n; i++)
scanf("%d",&a[i]);
int low = ,high = M,mid;
int ans = ;
while(low<=high)
{
mid = (low+high)>>;
if(cal(mid)==)
high = mid-;
else
{
low = mid+;
ans = max(ans,mid);
}
}
cout<<ans<<endl;
return ;
}

D

对于

k=1 ,ans = L。

连续偶奇异或是为1的 比如10 11    12 13等 ,而奇偶则是不一定的

k= 2, 如果l%2==0,ans = L^(L+1)=1 ,否则要根据R-L+1的取值决定

k= 4 ,如果L%2=0,ans = L^(L+1)^(L+2)^(L+3)  = 0,否则如果R-L+1>4 也是为偶奇偶奇=0的,若R-L+1=4 就可转化为3的时候做。

k=3 ,有可能为1也有可能为0 ,假设L-R范围内的三个数x,y,z异或为0,x,y,z不同,就设x>y>z,那么x,y已确定,那么就是尽可能让z大,

比如

x  100110001111   那么y值的第一位一定为1,不然z就为1就不符合假设y>z了,因为y<x,所以之后遇到x为0的位,y,z也是为0的,一旦再遇到一位1,就可以把y置为0,z置为1,再之后z就可以一直为1,而y的变化可以依据x,z而定。

x  100110001111...1

y  100001110000...0

z  000111111111...1

这样z将获得<R的最大值,再与L相比较就可以知道结果了。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
LL a[];
int di[];
void judge(LL l,LL r)
{
LL x = r;
LL i;
int g = ;
while(x)
{
di[g++] = x%;
x/=;
}
LL y = ;
LL z = ;
int flag = ;
y+=((LL)<<(g-));
for(i = g- ; i >= ; i--)
{
if(di[i])
{
flag = ;
z += ((LL)<<i);
}
else if(flag)
{
z+=((LL)<<i);
y+=((LL)<<i);
}
}
if(z>=l)
{
cout<<"0\n";
cout<<"3\n";
cout<<r<<" "<<y<<" "<<z<<endl;
}
else
{
cout<<"1\n";
cout<<"2\n";
if(l%)
cout<<l+<<" "<<l+<<endl;
else
cout<<l<<" "<<l+<<endl;
}
}
int main()
{
LL l,r,i,k;
cin>>l>>r>>k;
if(r==l)
{
cout<<l<<endl;
cout<<"1\n";
cout<<l<<endl;
return ;
}
if(l%==)
{
if(r-l+==||k<=)
{
if(k==)
{
cout<<l<<endl;
cout<<"1\n";
cout<<l<<endl;
}
else
{
cout<<"1\n";
cout<<"2\n";
cout<<l<<" "<<l+<<endl;
}
}
else if(r-l+==||k==)
{
judge(l,r);
}
else
{
cout<<"0\n";
cout<<"4\n";
for(i = l ; i < l + ; i++)
cout<<i<<" ";
puts("");
}
}
else
{
if(r-l+==||k<=)
{
if(k==||(r-l+==&&(l^(l+))>l))
{
cout<<l<<endl;
cout<<"1\n";
cout<<l<<endl;
}
else
{
if(r-l+==)
{
cout<<(l^(l+))<<endl;
cout<<"2\n";
cout<<l<<" "<<l+<<endl;
}
else
{
cout<<"1\n";
cout<<"2\n";
cout<<l+<<" "<<l+<<endl;
}
}
}
else if(r-l+==||k==)
{
judge(l,r);
}
else if(r-l+==)
{
int flag = ;
judge(l,r);
}
else
{
cout<<"0\n";
cout<<"4\n";
for(i = l+ ; i < l+ ; i++)
cout<<i<<" ";
puts("");
} }
return ;
}

Codeforces Round #262 (Div. 2)的更多相关文章

  1. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  2. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  3. Codeforces Round #262 (Div. 2) 460C. Present(二分)

    题目链接:http://codeforces.com/problemset/problem/460/C C. Present time limit per test 2 seconds memory ...

  4. codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/460/A题意:Vasya每天用掉一双袜子,她妈妈每m天给他送一双袜子,Vasya一开始有n双袜子, ...

  5. Codeforces Round #262 (Div. 2) E. Roland and Rose 暴力

    E. Roland and Rose Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/pro ...

  6. Codeforces Round #262 (Div. 2)解题报告

    详见:http://robotcator.logdown.com/posts/221514-codeforces-round-262-div-2 1:A. Vasya and Socks   http ...

  7. Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)

    题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second mem ...

  8. Codeforces Round #262 (Div. 2) A B C

    题目链接 A. Vasya and Socks time limit per test:2 secondsmemory limit per test:256 megabytesinput:standa ...

  9. Codeforces Round #262 (Div. 2) 二分+贪心

    题目链接 B Little Dima and Equation 题意:给a, b,c 给一个公式,s(x)为x的各个位上的数字和,求有多少个x. 分析:直接枚举x肯定超时,会发现s(x)范围只有只有1 ...

随机推荐

  1. SeasLog-An effective,fast,stable log extension for PHP

    github: https://github.com/Neeke/SeasLog @author Chitao.Gao [neeke@php.net] @交流群 312910117 简介 为什么使用S ...

  2. 蓝牙—RFCOMM协议

    RFCOMM是一个简单的协议,其中针对9针RS-232串口仿真附加了部分条款.可支持在两个蓝牙设备之间同时保持高达60路的通信连接.RFCOMM的目的是针对如何在两个不同设备上的应用之间保证一条完整的 ...

  3. ASP.NET MVC中从前台页面视图(View)传递数据到后台控制器(Controller)方式

    方式一: 数据存储模型Model:此方式未用到数据存储模型Model,仅简单的字符串string型数据传递 前台接收显示数据视图View: <div style="height:300 ...

  4. 开源实体映射框架EmitMapper介绍

    开源实体映射框架EmitMapper介绍   综述       EmitMapper是一个开源实体映射框架,地址:http://emitmapper.codeplex.com/.       Emit ...

  5. Audio Session Interruption

    近期处理了一个挂断电话后,莫名手机开始播放音乐的Bug. 所以顺便在这总结一下,对于IOS的AudioSession中断的几种处理情况. 一.通过C语言的init方法配置interruptionl回调 ...

  6. Nhiberate (三)测试

    (一)添加数据: public void AddUser(User user) { ISession session = NhibernateFactory.GetInstance().GetSess ...

  7. lua语言三则特性

    pack和unpack 对于一个函数, 要将其入参转换为一个表, 则pack函数合适. 对于一个表要将其转换为 一个函数的入参, 则 lua原生提供的 unpack函数可以实现. do arrayDa ...

  8. Consolidated Seed Table Upgrade Patch(Patch 17204589)

    $ adop phase=apply patches= hotpatch=yes abandon=no Enter the APPS password: Enter the SYSTEM passwo ...

  9. Adobe CS6 全系列官方下载地址 (迅雷无效) Win Mac

    https://helpx.adobe.com/x-productkb/policy-pricing/cs6-product-downloads.html CS6 Design & Web P ...

  10. Eclipse下Tomcat插件的安装

    在Eclipse下安装Tomcat插件使开发,编译,发布变的相当的简单,下面就说一下安装的过程,很简单的: 1.先下载一个tomcat插件 地址:http://www.eclipsetotale.co ...