codeforces Gym 100735 D、E、G、H、I
http://codeforces.com/gym/100735
D题 直接暴力枚举 感觉这道题数据有点问题 为什么要先排下序才能过?不懂。。
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <vector>
using namespace std;
const int maxn = ;
const int maxm = 1e4+;
const int inf = 0x3f3f3f3f;
const double epx = 1e-;
typedef long long ll;
int n,m;
ll a[maxn];
int main()
{
while(cin>>n)
{
for(int i=; i<=n; i++)
{
scanf("%I64d",&a[i]);
}
sort(a+,a++n);
int ans=;
int visit[maxn];
memset(visit,,sizeof(visit));
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{ for(int k=;k<=n;k++)
{
if(visit[i]==&&visit[j]==&&visit[k]==&&i!=j&&j!=k&&i!=k&&a[i]+a[k]>a[j]&&a[i]+a[j]>a[k]&&a[j]+a[k]>a[i])
{
ans++;
visit[i]=,visit[j]=,visit[k]=;
}
}
}
}
printf("%d\n",ans);
}
}
E题 n*n的数字矩阵 横着 竖着 对角线 相加都等于val 可以推出 公式把矩阵 每行(或者每列)已有的数字加起来除以n-1=val 每行(每列)只有一个未知用val去减就好了。
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <vector>
using namespace std;
const int maxn = ;
const int maxm = 1e4+;
const int inf = 0x3f3f3f3f;
const double epx = 1e-;
typedef long long ll;
int n,m;
ll a[maxn][maxn];
int main()
{
cin>>n;
ll sum[maxn],zong=;
for(int i=; i<n; i++)
{
sum[i]=;
for(int j=; j<n; j++)
{
scanf("%I64d",&a[i][j]);
sum[i]+=a[i][j];
}
zong+=sum[i];
}
zong=zong/(n-);
for(int i=; i<n; i++)
{
for(int j=; j<n; j++)
{
ll x=a[i][j];
if(i==j)
x=zong-sum[i];
if(j==n-)
printf("%I64d\n",x);
else
printf("%I64d ",x);
}
}
}
G题 水题
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <vector>
using namespace std;
const int maxn = 1e5+;
const int maxm = 1e4+;
const int inf = 0x3f3f3f3f;
const double epx = 1e-;
typedef long long ll;
int n,m;
char a[maxn];
int main()
{
cin>>a;
int sum=,ans=;
int len=strlen(a);
for(int i=;i<len;i++)
{
if(a[i]=='')
ans++;
}
printf("%d\n",min(ans,len-ans));
}
H题 要用二分图最大匹配写 用dfs会T的很惨。
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <vector>
using namespace std;
const int maxn = ;
const int maxm = 1e4+;
const int inf = 0x3f3f3f3f;
const double epx = 1e-;
typedef long long ll;
int n;
char a[maxn][];
char s[maxn];
int len;
int visit[maxn];
int m[maxn][maxn];
int match[maxn];
bool found(int x)
{
for(int i=;i<=n;i++)
{
if(m[x][i]==&&visit[i]==)
{
visit[i]=;
if(match[i]==-||found(match[i]))
{
match[i]=x;
return true;
}
}
}
return false;
}
int main()
{
cin>>s>>n;
len=strlen(s);
memset(m,,sizeof(m));
memset(match,-,sizeof(match));
for(int i=; i<=n; i++)
{
for(int j=; j<; j++)
{
cin>>a[i][j];
for(int k=;k<len;k++)
{
if(a[i][j]==s[k])
m[k][i]=;
}
}
} int ans=;
for(int i=;i<len;i++)
{
memset(visit,,sizeof(visit));
if(found(i))
ans++;
}
if(ans==len)
printf("YES\n");
else
printf("NO\n");
}
I题 大数加法 Java大数类
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[])
{
Scanner cin = new Scanner(System.in);
BigInteger a, b,c,a1,b1,c1;
while (cin.hasNext())
{
a = cin.nextBigInteger();
b = cin.nextBigInteger();
c = cin.nextBigInteger();
a1=a.add(a);b1=b.add(b);c1=c.add(c);
int flag=0;
if(a.add(b).compareTo(c)==0)
flag=1;
else if(a.add(c).compareTo(b)==0)
flag=1;
else if(b.add(c).compareTo(a)==0)
flag=1;
else if(a1.compareTo(b)==0)
flag=1;
else if(a1.compareTo(c)==0)
flag=1;
else if(b1.compareTo(a)==0)
flag=1;
else if(b1.compareTo(c)==0)
flag=1;
else if(c1.compareTo(b)==0)
flag=1;
else if(c1.compareTo(a)==0)
flag=1;
if(flag==1)
System.out.println("YES");
else
System.out.println("NO");
}
}
}
菜菜菜 就出了几道水题
codeforces Gym 100735 D、E、G、H、I的更多相关文章
- sed初理多行合并+sed之G、H、g、h使用+sed n/N使用说明
转载:[shell]sed处理多行合并 - seyjs - 博客园 (cnblogs.com) 文件格式 table=t1 name owner address table=t2 id text co ...
- 2019年第十届蓝桥杯【C++省赛B组】D、E、G、H、I题解
这场有几道题目思路,在之前比赛中遇到过 D. 数的分解 #枚举 题意 将\(2019\)分解成\(3\)个各不相同的正整数之和,并且每个正整数都不包含数字\(2\)和\(4\),一共有多少种分解方法? ...
- Python基础-生物信息:找出基因,生物学家使用字母A、C、T和G构成的字符串建模一个基因组。
生物信息:找出基因,生物学家使用字母A.C.T和G构成的字符串建模一个基因组.一个基因是基因组的子串,它从三元组ATG后开始在三元组TAG.TAA或TGA之前结束.此外,基因字符串的长度是3的倍数,而 ...
- Codeforces GYM 100876 J - Buying roads 题解
Codeforces GYM 100876 J - Buying roads 题解 才不是因为有了图床来测试一下呢,哼( 题意 给你\(N\)个点,\(M\)条带权边的无向图,选出\(K\)条边,使得 ...
- Codeforces Gym 101252D&&floyd判圈算法学习笔记
一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...
- HDU 5544 Ba Gua Zhen ( 2015 CCPC 南阳 C、DFS+时间戳搜独立回路、线性基 )
题目链接 题意 : 给出一副简单图.要你找出一个回路.使得其路径上边权的异或和最大 分析 : 类似的题有 BZOJ 2115 对于这种异或最长路的题目(走过的边可以重复走) 答案必定是由一条简单路径( ...
- CodeForces Gym 100213F Counterfeit Money
CodeForces Gym题目页面传送门 有\(1\)个\(n1\times m1\)的字符矩阵\(a\)和\(1\)个\(n2\times m2\)的字符矩阵\(b\),求\(a,b\)的最大公共 ...
- 【java基础学习一】int[]、Integer[]、String[] 排序( 正序、倒叙)、去重
调用: //重复项有9.5.1.2 int[] ints = new int[]{9,4,7,8,2,5,1,6,2,5,9,1}; arrayIntTest(ints); ///////////// ...
- Windows网络驱动、NDIS驱动(微端口驱动、中间层驱动、协议驱动)、TDI驱动(网络传输层过滤)、WFP(Windows Filtering Platform)
catalog . 引言 . Windows 2000网络结构和OSI模型 . NDIS驱动 . NDIS微端口驱动编程实例 . NDIS中间层驱动编程实例 . NDIS协议层驱动编程实例 . TDI ...
随机推荐
- C#代码规范(简版)
C#项目代码规范 目的 1.方便代码的交流和维护. 2.不影响编码的效率,不与大众习惯冲突. 3.使代码更美观.阅读更方便. 4.使代码的逻辑更清晰.更易于理解. 在C#中通常使用的两种编码方式如下 ...
- .NET 出现参数化查询 需要参数但未提供该参数的错误
1.问题的来源 在.NET或者C#中,我们一般执行sql语句的话,推荐使用参数化查询,这样可以避免sql注入的攻击,但是,我在使用参数化查询的时候 出现了以下的错误,详细如下图: 图一这是写sql语句 ...
- Visual Studio 2013 错误系统找不到指定文件,0x80070002
错误:Visual Studio 2013 按照成功后,可以创建空web项目,但不能建webform 和 mvc 项目. 提示系统找不到指定文件,0x80070002. 解决方式: Step1: Wi ...
- Node.js——开放静态资源原生写法
借助了mime第三方包,根据请求地址请求的文件后缀,设置content-type
- Winsock2_WSADATA
使用Winsock2进行win下网络编程的第一步是初始化Winsock.其中需要创建一个WSADATA类型的变量,这个变量用来保存Windows socket的实现信息. typedef struct ...
- Linux 的 Spinlock 在 MIPS 多核处理器中的设计与实现
引言 随着科技的发展,尤其是在嵌入式领域,高性能.低功耗的处理器成为众多厂商追逐的目标,但是由于技术和工艺的瓶颈,试图在单核处理器上达到这样的目标变得越发困难,于是人们提出了多核处理器的概念.多核处理 ...
- oracle数据库使用hint来让模糊查询走索引
在没有创建数据直方图之前,查询优化器是cbo,可能不会选择代价最低(效率最高)的方式查询. 先创建表 --日语假名表 CREATE TABLE JAPANESE_SOUNDMARK ( ID INTE ...
- 从Excel读取数据,然后分析相似的数据,多线程处理(多线程比较相似的字符串,统计出相似的数量及字符串)
之前的jar包有问题,现已修改. 需要的jar包,已修改 自己去Maven中央仓库下载jar包. excel数据: 直接上代码. 程序再度优化了一遍.之后如果想再度精准,可能需要建模,最近没空继续做了 ...
- Google Chrome浏览器调试
作为Web开发人员,我为什么喜欢Google Chrome浏览器 [原文地址:http://www.cnblogs.com/QLeelulu/archive/2011/08/28/2156402.ht ...
- (3)Gojs model简介
(3)Gojs model简介 在GoJS中,model用来存储表的基本数据,包括node.link等具体对象和属性,与其在视觉上的展示效果不相关.model中往往只保存相对简单的数据,最方便且持久化 ...