Codeforces Round #195 (Div. 2)
记次CF吧 1题。。。B题。。因为循环的i没设成long long 却参与了运算 结果就悲剧了 一直交 一直挂 。。上题
A 水。。 第一次少了个空格还。。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define LL long long
LL x,y;
int main()
{
int i,j,k,n,m;
cin>>x>>y;
if((x<&&y>)||(x>&&y<))
{
LL b = y-x;
if(b<)
cout<<""<<" "<<b<<" "<<-b<<" "<<""<<endl;
else
cout<<-b<<" "<<"0 "<<""<<" "<<b<<endl;
}
else
{
LL b = y+x;
if(b>)
cout<<""<<" "<<b<<" "<<b<<" "<<""<<endl;
else
cout<<b<<" "<<""<<" "<<"0 "<<b<<endl;
}
return ;
}
B题 大体画画 就出来了 求下和加加
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
#define eps 1e-6
int main()
{
long long m,r,i;
cin>>m>>r;
double s =,s1=;
for(i = ; i <= m ; i++)
{
s = ;
if(i>)
s+=(i-)*(i-)*r+(i-2.0)*sqrt(2.0)**r+sqrt(2.0)*r+*r;
else
s+=(i-)*i*r+(i-)*sqrt(2.0)*r;
if(m-i>=)
s+=(m-i-)*(m-i)*r+(m-i-)*sqrt(2.0)**r+*r+sqrt(2.0)*r+*r;
else
s+=(m-i)*(m-i+)*r+(m-i)*sqrt(2.0)*r+*r;
s1+=s/m;
}
printf("%.10f\n",s1/m);
return ;
}
往后就没再看 一直在交B 7次WA啊啊 泪~~
补道C题
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#define N 100010
#define LL long long
using namespace std;
struct node
{
LL a;
int d[],k;
}q[N];
int f[];
void digit(int e)
{
int g=;
LL y = q[e].a;
while(y)
{
int x = y%;
g++;
q[e].d[g] = x;
y/=;
}
q[e].k = g;
}
bool cmp(node a,node b)
{
return a.a<b.a;
}
int main()
{
int i,j,k,n,o,g;
cin>>n;
for(i = ; i <= n ;i++)
{
scanf("%d",&q[i].a);
digit(i);
}
sort(q+,q+n+,cmp);
o = ;
for(i = ; i >= ; i--)
{
memset(f,,sizeof(f));
for(j = n; j >= ; j--)
{
if(q[j].k<i)
break;
if(q[j].d[i]!=)
{
for(g = ; g < q[j].k ; g++)
if(q[j].d[g]==)
f[g] = ;
}
}
for(g = ; g < i ; g++)
if(!f[g]) break;
if(g==i)
{
o = g;
break;
}
}
int num = ;
for(i = n ; i >= ; i--)
if(q[i].d[o]==)
num++;
cout<<num<<endl;
int w=;
for(i = n ; i >= ; i--)
if(q[i].d[o]==)
{
if(w)
printf(" ");
w++;
cout<<q[i].a;
}
return ;
}
补道D题
根据费马小定理神马的求逆元 然后高端的算组合数取模
若第一个是1 则最后为0 若全是0且为偶数-》1 否则-》0 组合起来就可以求解了
100。。。。
0100。。
0010。。
0001。。。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
using namespace std;
#define mod 1000000007
#define LL long long
LL ff[];
LL fmod(LL a,LL k)
{
LL b = ;
while(k)
{
if(k&)
b = a*b%mod;
a = (a%mod)*(a%mod)%mod;
k/=;
}
return b;
}
LL cn(int n,int m)
{
LL ans,a;
ans = ff[n];
a = fmod((ff[n-m]*ff[m])%mod,mod-);
return (ans*a)%mod;
}
int main()
{
int i,j,k,n,m,g;
while(cin>>n>>m>>g)
{
LL s1=,s2=;
if(n==)
{
if(m==&&g==)
cout<<"1\n";
else if(m>&&g==)
cout<<"0\n";
else if(m==&&g==)
cout<<"0\n";
else
cout<<"1\n";
continue;
}
else if(m==)
{
if(n%==)
k = ;
else
k = ;
if(k==g)
cout<<"1\n";
else
cout<<"0\n";
continue;
}
ff[] = ;
for(i = ;i <= n+m;i ++)
{
ff[i] = (ff[i-]*i)%mod;
}
s1 = cn(n+m,m);
for(i = ;i <= n ; i+=)
{
if(m+n-i->=m-)
s2=(s2+cn(m+n-i-,m-))%mod;
}
if(m==&&n%!=)
s2++;
if(m==&&n%==)
s2--;
if(g==)
cout<<s2<<endl;
else
{
if(s1-s2<)
s1 = s1-s2+mod;
else
s1 = s1-s2;
cout<<s1<<endl;
}
}
return ;
}
Codeforces Round #195 (Div. 2)的更多相关文章
- Codeforces Round #195 (Div. 2) A. Vasily the Bear and Triangle
水题,注意数据范围即可 #include <iostream> #include <algorithm> #include <utility> using name ...
- Codeforces Round #195 (Div. 2) D题Vasily the Bear and Beautiful Strings
这场CF,脑子乱死啊...C题,搞了很长时间,结束了,才想到怎么做.B题,没看,D题,今天看了一下,很不错的组合题. 如果n和m都挺多的时候 以下情况都是变为1,根据偶数个0,最后将会为1,奇数个0, ...
- Codeforces Round #195 (Div. 2) 少部分题解
太困了于是没做...第二天看题蘑菇题居多就只切了简单的两个... A:直接输出... int main() { //FIN; //FOUT; int x,y; cin>>x>> ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
随机推荐
- ASP.NET 发送email
首先添加命名空间 using System.Net.Mail; /// <summary> /// 发送邮件 /// </summary> /// <param name ...
- 2016/01/19 javascript学习笔记-name属性
1. name属性只在少数html元素中有效:包括表单.表单元素.<iframe>和<img>元素. 基于name属性的值选取html元素,可以使用document对象的get ...
- 基于SMB共享文件夹的上传于下载
需要用到的jar包 http://pan.baidu.com/s/1skQFk77 1.首先在一台电脑上设置共享文件夹 ----上传下载的方法类 package com.strongit.tool ...
- 08_XML的解析_SAX解析
[对比SAX解析和DOM解析] * 在使用DOM解析XMl文档时,需要读取整个XML文档,在内存中架构代表整个DOM树的DOcument对象,从而对XML文档进行操作,在这种情况下,如果XML文档特别 ...
- SSH调试
<s:date>标签中若是用date数组或Calendar数组,则永远显示数组最后一个数. 试试List.Set.Map也不行. 看来只能够使用单个对象.或者在后台传送String 数组, ...
- jquery.animate用法
<!DOCTYPE html><html><head><script src="http://libs.baidu.com/jquery/1.10. ...
- PHP 提取图片img标记中的任意属性
PHP 提取图片img标记中的任意属性的简单实例. 复制代码代码如下: <?php /* PHP正则提取图片img标记中的任意属性 */ $str = '<center><im ...
- apache设置映射文件夹的配置方法
在apache的配置文件中加入以下配置 Alias /uploadImage F:/upload <Directory F:/upload/UploadFiles> Option ...
- Sqlserver循环嵌套
1.游标的状态,游标的开启游标的选择都是需要注意的. USE [ccnu] GO /****** Object: StoredProcedure [dbo].[P_ADD_DATA_XSBLHYCQK ...
- 测试MySQL事务管理
1.MySQL 版本 mysql> select version(); +------------+ | version() | +------------+ -log | +--------- ...