Codeforces 344B Simple Molecules】的更多相关文章

CodeForces - 344B id=46665" style="color:blue; text-decoration:none">Simple Molecules Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u id=46665" class="login ui-button ui-widget ui-state-default…
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); int ab=a+b-c,bc=b+c-a,ac=a+c-b; if(ab>=0&&bc>=0&&ac>=0&&ab%2==0&&bc%2==0&&ac%2==0)…
题目链接:http://codeforces.com/problemset/problem/344/B 题目意思:这句话是解题的关键: The number of bonds of an atom in the molecule must be equal to its valence number. 给定三个原子的化学价,规定化学价数等于该原子与另外两个原子所连接的原子键之和. 又一次把简单问题复杂化了.....(以下注释部分读者可以忽略) /* 一开始三重循环枚举,绝对超时(10^6 * 1…
Simple Molecules time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecul…
link:http://codeforces.com/contest/344/problem/B 刚开始想复杂了.一开始就想当然地以为可以有多个点,其实,人家题目要求只有3个点啊! 然后题目就简单了. A.B.C代表原子的化合价 x.y.z代表原子之间的化学键 首先x+y+z一定为偶数,否则不可能有解. 那么可以列出一个三元一次的方程组,由3个方程组成,可以求出唯一解. 判断有解的唯一限制条件是:不能出现负数. #include <cstdlib> #include <cstdio>…
E. Simple Skewness time limit per test:3 seconds memory limit per test:256 megabytes input:standard input output:standard output Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list…
原题: http://codeforces.com/contest/570/problem/B 题目: Simple Game time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output One day Misha and Andrew were playing a very simple game. First, each player choo…
题目连接:http://codeforces.com/contest/962/problem/F 题目大意是定义一个simple cycle为从一个节点开始绕环走一遍能经过simple cycle内任何一个节点,并且不超过一次. 因为是无向图,而且是环,即为连通分量,所以模型转化为求点双连通分量,依据题意求得的点双连通分量需要满足题目simple cycle的定义,所以当一个点双连通分量的边数量和点数量相等时才能构成simple cycle,在tarjan求割点的时候,需要存储点双联通分量的点和…
http://codeforces.com/contest/344/problem/B #include <cstdio> #include <cstring> using namespace std; int main() { int a,b,c; ,t2=,t3=; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { bool flag=false; ; i<=a; i++) { t1=i; ) { t…
题目链接: http://codeforces.com/contest/665/problem/C 题意: 改变最少的字符,使得最终序列无相同的连续的字符. 分析: 对每一个与前一个字符相同的字符,枚举满足条件的字符进行替换. 代码: #include<iostream> using namespace std; int main (void) { string s;cin>>s; int n = s.length(); for(int i = 1; i < n; i++){…
题目链接: http://codeforces.com/problemset/problem/665/D 题意: 给定序列,从中找出最大的子集,使得子集中的数两两相加均为质数. 分析: 貌似有用最大团做的.可是不会,名字太难听也不是很想学. n只有1000,暴力一发. 如果集合中有1的话,把所有1都放进去,我们最多再找一个偶数. 如果不考虑1的话,两个奇数,两个偶数相加均为偶数,所以最多找一个奇数和一个偶数. 枚举之后判断一下是否为质数就好了. 我觉得整个序列找不到两两相加为质数的时候的说明不是…
题意: 给你n个数,让你从中选一个子集要求子集中的任何两个数相加都是质数. 思路: 一开始把自己坑了,各种想,后来发现一个简单的性质,那就是两个数相加的必要条件是这两个数之中必定一个奇数一个偶数,(除了含有1 集合以外,1+1等于2也是质数). 考虑两种情况,有1存在和1不存在这两种. 很显然1存在的情况下,所有的1都可以同时在集合中出现,要想集合最大不能加奇数,只能加偶数,那么我们看原始集合中是否有偶数加一是素数. 不考虑1的情况下,这样的子集最大是2,只有存在一个奇数一个偶数相加是质数的情况…
题意: 给你一堆无序数,寻找它的一个子堆,使得子堆的平均数减中位数最大. 数字的个数n<=2e5 0<=xi<=1e6. 思路: 首先可以证明这堆数一定是奇数个,证明方法是尝试在奇数个的有序数列中加入一个数字求平均值和中位数各增加了多少.然后比较一下. 也可以考虑偶数个的序列去掉中间两个中较大的数,差值不会减小. 所以中位数一定是原先堆里的数,我们可以枚举每一个数,然后二分查找范围. 二分查找范围的原理是,随着字串长度的增加,那么差值是先增大后减小的,所以我们枚举某点和它相邻的点的斜率(…
题目链接 给一个数列, 让你选出其中的m个数, 使得选出的数中任意两个数之和都为质数, m尽可能的大. 首先, 除了1以外的任意两个相同的数相加结果都不是质数. 然后, 不考虑1的话, 选出的数的个数不大于2. 假设我们选了3个数, a1, a2, a3. a1+a2是质数的话, 那么a1, a2中一个为奇数一个为偶数. 那么如果a3无论为奇数或偶数都无法满足条件了. 所以我们按1出现的次数分类讨论一下就好了. #include <iostream> #include <vector&g…
题目链接 给n个数, 让你去掉一些数, 使得剩下的数的平均值-中位数的差值最大. 先将数组排序, 然后枚举每一个数作为中位数的情况, 对于每个枚举的数, 三分它的左右区间长度找到一个平均值最大的情况, 平均值最大, 肯定是它左边的数是靠近他的那几个数, 右边的数是最右边的那几个数. 然后所有情况取最大值. 三分的写法lmid = (l*2+r)/2, rmid = (l+r*2+2)/3, 学到了. 并且求平均值最好不要除,比如说平均数-中位数, 那么写成   这几个数的和-中位数*长度. #i…
相同的一段字母变一下就可以. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<stack> #include<queue> #include<string> #include<algorithm> using namespace std; +; char s[maxn…
//题意:给你n个数(可能有重复),问你最多可以取出多少个数使得任意两个数之和为质数.//题解:以为是个C(2,n)复杂度,结果手摸几组,发现从奇偶性考虑,只有两种情况:有1,可以取出所有的1,并可以再取一个偶数(如果这个偶数+1是质数).没有1,如果取了一个奇质数,那只能再拿一个2(如果有2的话). 坑:一度把题目记错了,以为输入的是质数,结果比赛的时候一直wa到orz ac代码: #include<iostream> #include<stdio.h> #include<…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule. A molecule c…
题目描述:  A Simple Task time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or…
这次比赛出的题真是前所未有的水!只用了一小时零十分钟就过了前4道题,不过E题还是没有在比赛时做出来,今天上午我又把E题做了一遍,发现其实也很水.昨天晚上人品爆发,居然排到Rank 55,运气好的话没准能领到T-shirt.除此之外,锁上程序之后,看到一个人数组开小了,我还提交了一个大数据,成功Hack了一次,然后Room排名顿时升到第1. My submissions     # When Who Problem Lang Verdict Time Memory 4474604 Sep 15,…
A. Magnets 模拟. B. Simple Molecules 设12.13.23边的条数,列出三个等式,解即可. C. Rational Resistance 题目每次扩展的电阻之一是1Ω的,所以假设当前的电阻为\(\frac{a}{b}\)会变成\(\frac{a+b}{b}\)或\(\frac{a}{a+b}\),其实就是求gcd的过程. D. Alternating Current 若出现连续两个相同的符号,其实线的方向是不变的,最后就是转化成括号匹配. E. Read Time…
http://open.sina.com.cn/course/id_1047/ What scientists do is not just collect data and collect facts and stick them in big books,and what's more ,their main job is to talk to each other about what they don't know. They really do care about a kind of…
E. A Simple Task Problem's Link: http://codeforces.com/problemset/problem/558/E Mean: 给定一个字符串,有q次操作,每次操作将(l,r)内的字符升序或降序排列,输出q次操作后的字符串. analyse: 基本思想是计数排序. 所谓计数排序,是对一个元素分布较集中的数字集群进行排序的算法,时间复杂度为O(n),但使用条件很苛刻.首先对n个数扫一遍,映射出每个数字出现的次数,然后再O(n)扫一遍处理出:对于数字ai,…
题目链接:http://codeforces.com/contest/558/problem/E E. A Simple Task time limit per test5 seconds memory limit per test512 megabytes inputstandard input outputstandard output   This task is very simple. Given a string S of length n and q queries each qu…
E. A Simple Task 题目连接: http://www.codeforces.com/contest/558/problem/E Description This task is very simple. Given a string S of length n and q queries each query is on the format i j k which means sort the substring consisting of the characters from…
题目链接: http://codeforces.com/problemset/problem/558/E E. A Simple Task time limit per test5 secondsmemory limit per test512 megabytes 问题描述 This task is very simple. Given a string S of length n and q queries each query is on the format i j k which mea…
D. Simple Subset 题目连接: http://www.codeforces.com/contest/665/problem/D Description A tuple of positive integers {x1, x2, ..., xk} is called simple if for all pairs of positive integers (i,  j) (1  ≤ i  <  j ≤ k), xi  +  xj is a prime. You are given a…
C. Simple Strings 题目连接: http://www.codeforces.com/contest/665/problem/C Description zscoder loves simple strings! A string t is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add a…
A Simple Task CodeForces - 11D 题意:输出一个无向图的简单环数量.简单环指无重复边的环.保证图无重边自环. ans[i][j]表示"包含i中的点,以i中第一个点为起点,以j为终点"的路径条数. 对于某个i,枚举当前终点j(显然不能是首个点),产生一个状态.再枚举上一次终点k,如果能转移就转移. 如果i中点数大于2且j到i中第一个点有路,就认为产生了环.最后每个环记录了两遍,要除以2. #include<cstdio> #include<c…
time limit per test5 seconds memory limit per test512 megabytes inputstandard input outputstandard output This task is very simple. Given a string S of length n and q queries each query is on the format i j k which means sort the substring consisting…