C. Rational Resistance time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certai…
Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake muffins in her bakery, Masha needs to establish flour supply from so…
A. Rational Resistance Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/A Description Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resista…
C. Rational Resistance time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certai…
这次比赛出的题真是前所未有的水!只用了一小时零十分钟就过了前4道题,不过E题还是没有在比赛时做出来,今天上午我又把E题做了一遍,发现其实也很水.昨天晚上人品爆发,居然排到Rank 55,运气好的话没准能领到T-shirt.除此之外,锁上程序之后,看到一个人数组开小了,我还提交了一个大数据,成功Hack了一次,然后Room排名顿时升到第1. My submissions     # When Who Problem Lang Verdict Time Memory 4474604 Sep 15,…
题目地址:http://codeforces.com/contest/460/problem/B 这题乍一看没思路.可是细致分析下会发现,s(x)是一个从1到81的数,不管x是多少.所以能够枚举1到81,这样就转化成了一个一元一次方程.直接求解x就能够了.这时候还要推断x是否在1到10^9之间,而且它的各位数之和是s(x). 这题脑残了两次.. . 第一次是写成了<=10^9..然后发现错误后,就又改了回来. .可是发现10^9是不可能的,. ... 代码例如以下: #include <ios…
http://http://codeforces.com/problemset/problem/343/A A. Rational Resistance time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike is building a time machine in his spare time.…
Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Description Input Output Print exactly one integer — the beauty of the product of the strings. Sample Input 3aba Sample Output 3 题解:这个题的思维难度其实不大,需要维护什么东西很容易想到,或…
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问题的思路: // // 第一个假设a字符串和b字符串相等,说直接YES // 假设b串全是0,直接YES // 注意到a串有一个性质,1的个数不会超过本身的加1. // a有个1的上限设为x,b有个1的个数设为y,则假设x < y // 那么直接NO. // // 如今普通情况下.就是模拟啦,找到a…
Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Input The first line contains a single integer nn (2≤n≤150000) — the number of kittens. Each of the following n−1lines contains integers xi and yi (1≤xi,…
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Equation 题目大意:有一个数字n,让你给出任意两个合数a,b满足a - b = n. 我们知道大于2的偶数都是合数,那么如果n为奇数,只要n加上一个奇数合数一定也为合数,如果n为偶数,那么n加上一个偶数合数也一定为合数. 因为只求任意一组,就直接选择4,9,若为奇数输出 +n 和9,偶数输出 +…
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原点开始走,方向自选(<- or ->),在过程中,若遇到一个权值>0的点,则将此权值计入答案,并归零.当次.此方向上的所有点均为0后,输出此时的答案. 然后,进行分析: 我们很容易想到这是一个贪心,我们将正的和负的分别存入两个数组,最初的方向为: \(zhengsum > fusum…
职务地址:http://codeforces.com/contest/460/problem/C 这个题是用二分枚举最小值.然后推断是否能在规定的次数内使得全部的数都达到这个值.推断的时候要用贪心的方法推断,从左往右遍历.这时候须要让每次浇花的范围尽量向右.所以当到达一个不得不浇花的地方时,要继续占用所须要的浇花次数.当浇花次数不够用的时候,就说明无法达到. 在我的代码中,c数组是记录当前到了该点的时候浇花范围的最右界.表示到了这个地方的时候少了多少次覆盖.y就代表当前这个数被多少个浇花范围覆盖…
先送上一篇题解(虽然全英文的):http://codeforces.com/blog/entry/18034 A题:http://codeforces.com/problemset/problem/546/A 没什么好说的,SB题 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm&…
Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input Output The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwis…
Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input The first and only line contains a single integer mm (1≤m≤100000,1≤m≤100000). Output Print a single integer — the expected length of the array aa writte…
久しぶり! 发现的一道有意思的题,想了半天都没有找到规律,结果竟然是思路题..(在大佬题解的帮助下) 原题戳>>https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1305<< 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整: fun(A)     sum = 0     for i = 1 to A.length         for j = i+1 to A.length  …
思路: 思路题 题目诡异地给了一组可行匹配 肯定有用啊-. 就把那组可行的解 女向男连一条有向边 如果男喜欢女 男向女连一条有向边 跑一边Tarjan就行了 (这个时候 环里的都能选 "增广环"嘛) 嗯 就搞定了 //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 4005 int first[N…
传送门 解题思路 比较好想的一道思路题,结果有个地方没开\(long\) \(long\) \(wa\)了三次..其实就是模仿一下树链剖分,重新定义重儿子,一个点的重儿子为所有儿子中到叶节点权值最大的点,然后就和树链剖分一样\(dfs\)一遍,把那些链的顶端的\(sum\)值放到一个数组排个序. 代码 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include&…
传送门 解题思路 比较好想的思路题.首先肯定要把原序列转化一下,大于\(k\)的变成\(1\),小于\(k\)的变成\(-1\),然后求一个前缀和,还要用\(cnt[]\)记录一下前缀和每个数出现了几次,然后统计答案的时候从\(1\)循环到\(k\),每次转化为前缀和相减即可. 代码 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAXN = 10…
C - Sorting Railway Cars   Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   CodeForces 606C Description An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are…
C. They Are Everywhere time limit per test: 2 seconds memory limit per test:256 megabytes input: standard input output: standard output Sergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from le…
C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwi…
Description Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value. However, all Mike has is lots of identical resistors with unit resistance R0 = 1. Elements with othe…
C题就是个dp,把原数据排序去重之后得到新序列,设dp[i]表示在前i个数中取得最大分数,那么: if(a[i] != a[i-1]+1)   dp[i] = cnt[a[i]]*a[i] + dp[i-1]; else      dp[i] = dp[i] = max(dp[i-1],a[i]*cnt[a[i]] + dp[i-2]),    dp[i-1]表示不取a[i], a[i]*cnt[a[i]] + dp[i-2]表示取a[i]. cnt[a[i]]是a[i]出现的次数. #incl…
C. Replacement time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Re…
C. History time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarpus likes studying at school a lot and he is always diligent about his homework. Polycarpus has never had any problems wit…
题意:给若干个阻值为1的电阻,要得到阻值为a/b的电阻最少需要多少个. 思路:令a=mb+n,则a/b=m+n/b=m+1/(b/n),令f(a,b)表示得到a/b的电阻的答案,由f(a,b)=f(b,a),有: f(a,b)=a/b + f(a%b,b)=a/b+f(b,a%b) (1)由于将所有的电阻之间的关系改变一下,串联变成并联,并联变成串联,阻值变成之前的倒数,所以f(a,b)=f(b,a)成立. (2)现在再证一下:串联变成并联,并联变成串联,阻值变成之前的倒数.考虑任一个电路,一定…
打表发现规律,对4取模为0的结果为4,否则为0,因此只需要判断输入的数据是不是被4整出即可,数据最大可能是100000位的整数,判断能否被4整出不能直接去判断,只需要判断最后两位(如果有)或一位能否被4整出即可. #include<map> #include<cmath> #include<queue> #include<cstdio> #include<string> #include<vector> #include<cst…
A---Birthday http://codeforces.com/contest/1068/problem/A 题意: 有n种硬币,m个人.m个人要给Ivan送硬币,每个人送的硬币都要互不相同但数量一样.Ivan现在已经有k种了,具体哪k种不知道.现在要求朋友们送的硬币至少有l种是IVan没有的. 思路: 刚开始想的是l/m取上整.后来发现题意是不知道Ivan有的是哪几种,为了保证一定至少l种的话,就需要(l+k)/m取上整. 不可能的情况是人数乘每个人送的硬币数超过n. 用longlong…