Codeforces 11B Jumping Jack(数学)】的更多相关文章

B. Jumping Jack time limit per test 1 second memory limit per test 64 megabytes input standard input output standard output Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get…
Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be e…
B. Jumping Jack 题目连接: http://www.codeforces.com/contest/11/problem/B Description Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has d…
题意: 给一个数X. 起始点为坐标0.第1步跳1格,第2步跳2格,第3步跳3格,.....以此类推. 每次可以向左跳或向右跳. 问最少跳几步可以到坐标X. 思路: 假设X是正数. 最快逼近X的方法是不停向右走.如果越过了X,假设到了X1,则必有X1-X小于最后一步d. 如果X1-X是偶数,将之前的某个x变为-x.则可以到X. 如果X1-X是奇数,因为将之前的某个x变为-x,实际是后退2x格.所以必定要再向右走一步.直到X1-X是偶数.(其实只要走一步或两步) X是负数的情况和X是正数的情况一样.…
Jumping Jack CodeForces - 11B 就是一个贪心. 基本思路: 正负没有关系,先取绝对值. 首先跳过头,然后考虑怎么回来. 设超过头的步数为kk.如果kk为偶数,那么直接在前面跳过来的步数中选一个kk/2的步数,改成反着跳即可,不需要额外步数. 如果kk为奇数: 显然如果只把前面跳的改成反着跳不可能导致位置与目标位置差值的奇偶性变化,而kk为奇数,需要达到的差值0是偶数,因此一定需要额外步数. 那么可能有两种情况: 设当前已经跳了p步.如果p为偶数,那么这一步的下一步(p…
B. Jumping Jack Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequen…
题目:http://codeforces.com/problemset/problem/198/B Jumping on Walls time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya plays a computer game with ninjas. At this stage Vasya's ninja shou…
题意:第一行给两个数,n 和 A,n 表示有n 个骰子,A表示 n 个骰子掷出的数的和.第二行给出n个数,表示第n个骰子所能掷出的最大的数,这些骰子都有问题, 可能或多或少的掷不出几个数,输出n个骰子掷不出的数的个数. 析:我们只要考虑两个极端就好,考由其他骰子投出的最大值和最小值,还有自身在最大值和最小值,作一个数学运算就OK了.公式如下: 骰子的最大值-能投的最大值+能投的最小值-1. 代码如下: #include <cstdio> #include <string> #inc…
题意:给你x%ci=bi(x未知),是否能确定x%k的值(k已知) ——数学相关知识: 首先:我们知道一些事情,对于k,假设有ci%k==0,那么一定能确定x%k的值,比如k=5和ci=20,知道x%20=y,那么ans=x%k=y%5; 介绍(互质版)中国剩余定理,假设已知m1,m2,mn,两两互质,且又知道x%m1,x%m2..x%mn分别等于多少 设M=m1*m2*m3..mn,那么x在模M的剩余系下只有唯一解(也就是知道了上面的模线性方程组,就可以求出x%M等于多少) ——此题解法 针对…
Garage 题目连接: http://codeforces.com/gym/100269/attachments Description Wow! What a lucky day! Your company has just won a social contract for building a garage complex. Almost all formalities are done: contract payment is already transferred to your a…