A:

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int n,m;
int ans;
int a,b;
int main()
{
//freopen("input.txt","r",stdin);
cin>>n>>m;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a>>b;
if(a||b)
ans++;
}
}
cout<<ans<<endl;
}

B:

暴力,pow函数误差太大。。。。

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int n,k,f;
int a[100005];
int b[100005];
int ans[100005];
int cnt=0;
long long res=1LL;
int xx;
const long long gg=1e9+7;
int g[15]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};
int main()
{
// freopen("input.txt","r",stdin);
scanf("%d %d",&n,&k);
f=n/k;
xx=g[k]-1;
for(int i=0;i<f;i++)
scanf("%d",&a[i]);
for(int i=0;i<f;i++)
scanf("%d",&b[i]);
for(int i=0;i<f;i++)
{
int w1=xx/a[i]+1;
int y1=g[k-1]*b[i];
int y2=g[k-1]*(b[i]+1);
int mod1=y1%a[i];
if(mod1==0)
y1-=a[i];
int mod2=y2%a[i];
if(mod2==0)
y2-=a[i];
ans[i]=w1-((y2-mod2)-(y1+a[i]-mod1))/a[i]-1;
res=(res*(long long)ans[i])%gg;
// printf("%d %d %d %d\n",w1,y1+a[i]-mod1,y2-mod2,ans[i]);
}
printf("%I64d\n",res);
}

C:

一道博弈论,正面很难想,那么就从反面想:

如果剩下的是L,R;

A,他要剩下的最小,他肯定是删L,R外面的。

B,他要剩下的大,肯定是删L,R里面的。

所以答案肯定就是a[x]-a[x-n/2],因为小的那个先取,所以取min。

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
typedef long long LL;
int n;
LL a[200000+5];
int main()
{
//freopen("input.txt","r",stdin);
LL ans=1<<30;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%I64d",&a[i]);
sort(a+1,a+n+1);
for(int i=n/2+1;i<=n;i++)
{
ans=min(ans,a[i]-a[i-n/2]);
}
printf("%I64d\n",ans);
}

codeforces #330 div2的更多相关文章

  1. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  2. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  3. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  4. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  5. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  6. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  7. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  8. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

  9. codeforces round367 div2.C (DP)

    题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; ...

随机推荐

  1. JwPlayer播放器【去除Logo、去除版本信息】

    效果图: <html> <head> <title>JwPlayer播放器@杯中红茶</title> <script type="tex ...

  2. ongl三种符号的使用

    1.#符号 访问非根对象属性,由于Struts2中值栈被视为根对象,所以访问其他非根对象时,需要加#前缀.实际上,#相当于ActionContext.getContext(): 用于过滤和投影(pro ...

  3. C++服务器设计(六):设备连接的生命周期管理

    生命周期介绍 每一个服务器系统的新连接从建立开始时,均会经历多个阶段.比如连接的建立,登录的验证,退出前的资源释放等.同时在具体的消息处理中,还会遇到不可识别的消息事件,或者消息处理时出现数据错误等. ...

  4. poj3581Sequence(后缀数组)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Sequence Time Limit: 5000MS   Memory Limi ...

  5. JS的全局变量&局部变量

    <script> var i=10; //全局变量 j = 20; //全局变量 function(){ var i=30; //局部变量 h = 40; //全局变量 } </sc ...

  6. ipython的notebook

    ipython是增强的python交互式shell.而notebook是在浏览器上运行ipython ubuntu下安装: sudo apt-get install ipython3 sudo apt ...

  7. SQL Server 无法打开物理文件的 2 种解决办法

    解决方法: 方法1.无法打开可以能是没有权限.如果是这样以管理员身份运行Managerment Studio就可以了. 方法2.找到指定的数据库文件.右键属性-->安全-->勾上  ‘完全 ...

  8. wordpress教程之如何修改与制作wordpress的作者页面

    一.如何使用与创建作者页面 一般情况下,多数主题下都有author.php这个文件,这既是作者展示页面.如果发现自己正在使用的主题中没有author.php这个文件的话, Wordpress 会默认寻 ...

  9. BZOJ 1458 士兵占领

    http://www.lydsy.com/JudgeOnline/problem.php?id=1458 题意:n x m的棋盘,k个位置不能放,每行和每列都有要求至少的士兵,求能否有最少的满足条件的 ...

  10. plsql在64位机器下读取tnsname.ora 及oracle_home异常的解决办法

    问题是: 我在自己电脑(win7  64bit)上安装了oracle的64位数据库   通过sqlplus能正常连接 主要是安装pl/sql时   我是这样安装的1.在网上下载了个instantcli ...