大家好,我们选择的是Bubble Cup比赛Div2场次的J题,不用问我Bubble Cup是什么比赛,我也不清楚.总之是一场算法比赛就是了.可能是这个比赛知名度比较低吧,参与的人数也不是很多,我们选择了一道中等通过人数的J题,作为今天的题目. 链接:https://codeforces.com/contest/1424/problem/J 这题非常不错,是一道质量很高的数学题,也很符合我的胃口.因为没有太多的trick,有的只有思维和逻辑的碰撞. 题意 我们都知道对于两个数a和b来说,我们可以…
Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C家的距离是c  (A- >Rabbit   B- >Owl    C ->Eeyore),他不能连续两顿饭都在同一位朋友家里蹭 他现在位于A的家里, 请问他一天最少要跑多少路. 当然是要找一条最短的路折返跑了啊,是不是很简单. #include<bits/stdc++.h> us…
补一下codeforces前天教育场的题.当时只A了一道题. 大致题意: 定义一个x - y - counter :是一个加法计数器.初始值为0,之后可以任意选择+x或者+y而我们由每次累加结果的最后一位生成一个数列. 例如:4 - 2 - counter 进行+4 +4 +4 +4 +2 +4操作会生成数列 04824.每步要加上x或y是任意的. 给你一个数列(由0~9组成的字符串),问你0~9中全部两个数字生成这个包含这个子串的数列中间至少要插入多少数字.以10 * 10矩阵格式输出. 例如…
Codeforces 1165F1/F2 二分好题 传送门:https://codeforces.com/contest/1165/problem/F2 题意: 有n种物品,你对于第i个物品,你需要买\(k_i\)个,每个物品在非打折日买是2块钱,在打折日买是1块钱,每天你可以赚一块钱,现在告诉你一共有m个打折日,在第\(d_i\)天第\(t_i\)种物品打折,问你你最少需要多少天可以买完你需要的物品 题解: 二分 思路是这样的 根据题目的题意,你最多打工4e5天就可以买完所有的物品,所以我们可…
原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每个区间的和都为0.对于每个区间来说,设该区间长度为l,则让该区间都为0的操作数为l-1,例如:1 .1 .-3 .1的操作数为3,也就是说,若把a分成k个区间,则a所需要的总的操作数为n-k. 所以现在我们的目标就是把数组a划分为尽可能多的部分,这个时候我们可以用一个map,统计前缀和的个数,因为对…
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Halloween computer game. The game is played on a rectangular graveyard with a rectangular chapel in it. During the game, the player places new rectangul…
题目链接:https://codeforces.com/contest/1137/problem/D 题意: 交互题. 给定如下一个有向图: 现在十个人各有一枚棋子(编号 $0 \sim 9$),在不知道 $t,c$ 的值的情况下,他们同时从home出发,要最终到达flag处. 你只能选择移动哪几个人的棋子,但棋子移动到哪里由程序确定并给出. 题解: 看网上大佬一个神仙解法……看得我一愣一愣的…… 选定两颗棋子,第一颗每次都移动,第二颗隔一次移动一次.所以,进行了 $2t$ 次之后第二颗棋子刚好…
B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Finally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, b…
题目链接:http://codeforces.com/contest/472/problem/A 题目: 题意:哥德巴赫猜想是:一个大于2的素数一定可以表示为两个素数的和.此题则是将其修改为:一个大于等于12的数一定能表示为两个合数的和. 思路:这个很容易,下面是三种方法的代码. 奇偶法:一个数要么是奇数要么是偶数,众所周知大于2的偶数都是合数(因为都能被2整除嘛),所以只要把该数分解为两个非2的偶数的和即可. #include<bits/stdc++.h> using namespace s…
题目链接 http://codeforces.com/contest/1205/problem/C 题解 菜鸡永远做着变巨的梦 然而依然连div1BC题都不会做 要是那天去打cf怕是又要1题滚粗了.... 首先第一步显然是对于所有\(i+j\)为偶数的点(下称"偶点")求出\(a_{i,j}\)的值,对于所有\(i+j\)为奇数的点(下称"奇点")求出它们之间的相对关系.也就相当于强行令\(a_{1,2}=x\)之后求出所有奇点是\(x\)还是\(x\ \text{…
这题昨天晚上花了我1个小时50多分钟来搞,都没有搞定..后来看别人代码,直接暴力枚举第一个数的值来做..最多1000*1000的复杂度.当时怎么就没想到呢?还有为啥我的方法不对呢.. 暴力方法代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #define Mod 1000000007 using n…
题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it I hate I love 是来回循环的,不到最后一个每一次循环后面都输出 that,如果到最后则输出 it #include<bits/stdc++.h> using namespace std; int main() { ][]= {"I love ","I ha…
题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代码如下: #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 1e5 + 5; const int INF = 0x3f3f3f3f; vector<int> ans;…
Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86821#problem/I Description You are developing a new fashionable language that is not quite unlike C, C++, and Java. Since your langua…
题目地址:http://codeforces.com/contest/456/problem/C 脑残了. .DP仅仅DP到了n. . 应该DP到10w+的. . 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <cty…
这是一道蛮基础的构造题. - k         +(k - 1)      -(k - 2) 1 + k ,    1 ,         k ,             2,    ................... \  /        \  /           \  / k          k-1          k-2 如图所示,先构造第一个数,就是1 + k, 然后接下来每个数字和上个数相差k , k -1 , k -2 这样下来,最后一个数字就是一个中间的数字,过程就…
*这种题好像不用写题解... 题意: 一个人要改动别人的实验记录,实验记录记录是一个集合 实验记录本身满足:$max(X)-min(X)<=2$ 改动结果要求: 1.新的集合平均值和之前的一样 2.新的集合,$max(Y)<=max(X),min(Y)>=min(X)$ 求新一个和之前相同数值最少的新记录 题解: 首先考虑不同情况, 如果$max-min<=1$ :因为要保证平均值且值域受限制不变,无法改变值(增加一个值之后,要相应的把另外一值减小,而数值只有2/1种,改动没有意义…
题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these…
最近做到了一些有趣的散题,于是开个Blog记录一下吧… (如果有人想做这些题的话还是不要看题解吧…) 2017-03-16 PE 202 Laserbeam 题意:有一个正三角形的镜子屋,光线从$C$点射入,求恰好反射$12017639147$次后在$C$点射出的方案数. 题解:关于反射问题容易想到对称性,不断对称翻转正三角形,可以密铺整个平面,这样一条反射$k$次的路径对应平面上经过$k$条边的路径. 然后取$CB,CA$为基,把平面画正,就能得到一个带有平行的对角线的网格图,稍微观察一下就能…
题目链接:https://codeforces.com/problemset/problem/1099/E You are given an $n×m$ table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every $2×2$ square contains all four distinct characters. Your task is to find a nice table (…
C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: standard input output: standard output You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation".…
A. Search for Pretty Integers: 题目传送门 题目大意:给定N和M个数,从前一个数列和后一个数列中各取一个数,求最小值,相同算一位数. 一道水题,读入A.B数组后枚举i.j判断最小值即可,注意相同时只需要一位. B. Maximum of Maximums of Minimums: 题目传送门 题目大意:给定N和K,表示一个有N个数的数列和可以分成K段,使每一段中的最小值最大. 分类讨论,有三种情况: ·K=1,取最小值. ·K=2,分成两段取两段最小值的最大值. ·…
这种题就是难者不会,会者不难. 博客讲的很详细了 代码: #include <bits/stdc++.h> using namespace std; string s; int read() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) cin >> s; return n; } int main() { while(1) { printf("next 0\n");…
这个题就是一块大板子,问你能不能切成两块要求的长宽的两块板子,一开始是按切板子想的,感觉有点麻烦. 直接反过来想,把两块要求的板子拼起来,填成一个大板子,看填出来的这个板子和题目给的板子比较,小于等于就满足. 想了一下是四种情况,直接贴一下草稿纸上画的,丑乎乎的( ̄▽ ̄)/ 代码虽然长,但是直接复制粘贴条件改一下就可以. 代码: 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include&…
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…
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include <map> using n…
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is…
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In this problem your goal is to sort an array consisting of n integers in at most n swaps. For the given array find the sequence…
A I'm bored with life 水题 #include<bits/stdc++.h> using namespace std; typedef long long int LL; const LL N=1,M=1,MOD=1; int main() {//freopen("t.txt","r",stdin); ios::sync_with_stdio(false); LL a,b; scanf("%I64d%I64d",&…
A Mister B and Book Reading  O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef long long int LL; const LL N=1,M=1,MOD=1; int main() {//freopen("t.txt","r",stdin); int c,v0,v1,a,l; scanf("%d%d%d%d%d",&c,&…