题意:给你一个分数,问你在b进制下能否化成有限小数. 条件:p/q假如已是既约分数,那么如果q的质因数分解集合是b的子集,就可以化成有限小数,否则不能. 参见代码:反复从q中除去b和q的公因子部分,并缩小该公因子,继续尝试.直到q没有和b的公共因子为止,如果q变成了1,那么有限,否则无限. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; int T; ll q,p,b;…
题目链接:http://codeforces.com/contest/984 A. Game time limit per test:2 seconds memory limit per test:512 megabytes input:standard input output:standard output Two players play a game. Initially there are nn integers a1,a2,…,ana1,a2,…,an written on the…
B. Minesweeper time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games.…
C. Finite or not? time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given several queries. Each query consists of three integers p , q and b. You need to answer whether the result of…
C. Finite or not? time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given several queries. Each query consists of three integers pp, qq and bb. You need to answer whether the result o…
D. XOR-pyramid time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output For an array bb of length mm we define the function ff as f(b)={b[1]if m=1f(b[1]⊕b[2],b[2]⊕b[3],-,b[m−1]⊕b[m])otherwise,f(b)=…