每个加油的站可以确定一个alpha的上下界,比如,第i次加油站a[i],前面加了i次油,a[i]*10≤ alpha*i <(a[i]+1)*10. 取最大的下界,取最小的上界,看看两者之间的满足条件的下一个加油站是否唯一. 因为可以用分数,所有就没用double了 #include<bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }…
A continued fraction of height n is a fraction of form . You are given two rational numbers, one is represented as  and the other one is represented as a finite fraction of height n. Check if they are equal. Input The first line contains two space-se…
C. The Big Race time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a dist…
http://codeforces.com/problemset/problem/735/C 题意:有n个人打锦标赛,淘汰赛制度,即一个人和另一个人打,输的一方出局.问这n个人里面冠军最多能赢多少场,其中一个人和另一个人能打比赛当且仅当这两个人赢的局数相差不超过1. 思路:比赛的时候不会做..直接log2(n)交,果断错了.看题解:因为限制条件两个人能比赛当且仅当他们赢得局数相差不超过1,设F[x]为冠军赢x盘的时候需要的总人数,那么有这样的递推式:F[x] = F[x-1] + F[x-2].…
D. Spongebob and Squares Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m colum…
Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 Description In the near future any research and publications about cryptography are outlawed throughout the world on the grounds of national se…
http://codeforces.com/contest/716/problem/C 题目大意:感觉这道题还是好懂得吧. 思路:不断的通过列式子的出来了.首先我们定义level=i, uplevel = i + 1,目前的uplevel,然后我们可以知道,之前求出来的restgrade%level = 0,于是我们可以列出一个式子sqrt(k1 * i + grade) = uplevel * k.因为grade也是i的倍数,假定grade = k2 * i,所以我们写成sqrt((k1 +…
D. Winter is here time limit per test:3 seconds memory limit per test:256 megabytes input:standard input output:standard output Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the res…
https://vjudge.net/problem/48715/origin 题意:给出必定含1689四个数字的字符串,随意交换位置构造出能被7整除的数. 分析:数学思维题.观察发现1689的排列与7的余数恰好是0...6,那么利用这个性质去与串中其他数字相补出能被7整除的数,把1689固定在后四位,把0独自提取出来,其他数字为一组,把它们的数值*10000后mod7,根据得到的余数选择相应的1689排列,最后把0放在末尾(对结果正确性没有影响).代码: #include <cstdio>…
首先可以把 i mod n=j mod n的看成是同一类,i mod s=j mod s的也看成是同一类,也就是i mod gcd(s,n)的是同一类,很好理解,但是不会数学证明...大概可以想成数轴上一点可以向左向右跳s或n,根据错位相消能互达的两点最小距离为gcd(s,n),所以如果选择点i必须满足a(i)>=a(i+k*gcd(s, n)). 于是可以枚举d表示gcd(s, n),处理出所有可以被选择的点,1表示可选,0表示不可选,组成一个01序列,倍增一次后求出f[i]表示每一个点出发最…