codeforces #330 div2
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的更多相关文章
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- Codeforces #263 div2 解题报告
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...
- codeforces #round363 div2.C-Vacations (DP)
题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...
- codeforces round367 div2.C (DP)
题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; ...
随机推荐
- contentSize、contentInset和contentOffset
contentSize.contentInset和contentOffset 是 scrollView三个基本的属性. contentSize: The size of the content vie ...
- c# 运算符 ?、??、?:
用途:简化代码 说明: ? 是可空类型和运算符 int a; //a<>null int ?b; //b=null int ?c = b+1; //c=null; ?? 是空接合运算符 i ...
- ActiveMQ持久化消息(转)
ActiveMQ的另一个问题就是只要是软件就有可能挂掉,挂掉不可怕,怕的是挂掉之后把信息给丢了,所以本节分析一下几种持久化方式: 一.持久化为文件 ActiveMQ默认就支持这种方式,只要在发消息时设 ...
- n个数的最大公约、最小公倍数
#include <cstdio> #include <cstring> using namespace std; #define N 1010 //两个数的最大公约数和最小公 ...
- stl学习之模板
模板是实现代码重用机制的一种工具,实质就是实现类型参数化,即把类型定义为参数. C++提供两种模板:函数模板,类模板. template<typename T> //或者 templa ...
- user密码
一.修改密码 alter user hr identified by hr; password/passw hr: SYS@test>password hr Changing password ...
- mysql创建存储过程
-- 创建CREATE PROCEDURE proDelAccountById(IN in_accountid int) BEGIN -- 执行sql预计 END -- 调用 ; CALL proDe ...
- 用Python设计第一个游戏 - 零基础入门学习Python002
用Python设计第一个游戏 让编程改变世界 Change the world by program 有些鱼油可能会说,哇,小甲鱼你开玩笑呐!这这这这就上游戏啦?你不打算给我们讲讲变量,分支,循环,条 ...
- 工作中小知识点汇总(c#)
1.OOP 实体与数据库字段转换(注意 此时实体字段必须和数据库中查询的字段列名相同) list = ModelExtend.GetByDataTablePart<EZRate>(ds.T ...
- javascript之Date
JSON 日期转 JS日期,我们知道,日期类型转成JSON之后,返回的数据类似这样: /Date(1379944571737)/ 但是这种日期并不能直接显示,因为根本没有人知道这是什么意思,下面提供一 ...