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. poj1200Crazy Search (哈希)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Crazy Search Time Limit: 1000MS   Memory ...

  2. UVALive 4119 Always an integer (差分数列,模拟)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Always an integer Time Limit:3000MS     M ...

  3. (原+转)ubuntu16中莫名死机及重新安装显卡驱动

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5992693.html 参考网址: http://blog.csdn.net/u012581999/ar ...

  4. POJ2533:Longest Ordered Subsequence(LIS)

    Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence ...

  5. sitemap.xml 静态和动态生成页面 shopnc二次开发 动态生成sitemap.xml

    Sitemap 可方便网站管理员通知搜索引擎他们网站上有哪些可供抓取的网页.最简单的 Sitemap 形式,就是XML 文件,在其中列出网站中的网址以及关于每个网址的其他元数据(上次更新的时间.更改的 ...

  6. [C++程序设计]函数的递归调用

    在调用一个函数的过程中又出现直接或间接地调用 该函数本身,称为函数的递归(recursive)调用. 包含递归调用的函数称为递归函数. 在实现递归时,在时间和空间上的开销比较大 求n! #includ ...

  7. Gnome快捷键

    1.Gnome快捷键 http://wiki.ubuntu.org.cn/Gnome%E5%BF%AB%E6%8D%B7%E9%94%AE 2.

  8. 动态加载JS过程中如何判断JS加载完成

    在正常的加载过程中,js文件的加载是同步的,也就是说在js加载的过程中,浏览器会阻塞接下来的内容的解析.这时候,动态加载便显得尤为重要了,由于它是异步加载,因此,它可以在后台自动下载,并不会妨碍其它内 ...

  9. Windows7里的“计算器”你真的会用吗?

    “计算器”是不同Windows版本中的必备工具,虽然功能单一,但的确是人们日常工作中不可缺少的辅助工具,本文就来谈谈它的使用. 一.标准型和科学型两种面板 我们既可从Windows附件菜单中启动它,也 ...

  10. centos linux中怎么查看和修改计算机名/etc/sysconfig/network

    centos linux中怎么查看和修改计算机名 查看计算机名:在终端输入hostname 修改的话 hostname +计算机名(重启后失效)要永久修改的话要修改配置文件/etc/sysconfig ...