题意:给你一个分数,问你在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…
题意:定义,对于a数组的一个子区间[l,r],f[l,r]定义为对该子区间执行f操作的值.显然,有f[l,r]=f[l,r-1] xor f[l+1,r].又定义ans[l,r]为满足l<=i<=j<=r的f[i,j]的最大值.多次询问你某些区间的ans值. ans=max(f[l,r],ans[l,r-1],ans[l+1,r]),直接递推即可. #include<cstdio> #include<algorithm> using namespace std;…
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…
题目地址:http://codeforces.com/contest/984/problem/B 题目大意:扫雷游戏,给你一个n*m的地图,如果有炸弹,旁边的八个位置都会+1,问这幅图是不是正确的. 题解:把输入的地图转换为数字格式,自己重新按炸弹绘制一幅图,对比一下. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #…
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)=…
题目链接: https://cn.vjudge.net/contest/229761 A题: n个数字,两个人轮流去数字,直到剩下最后一个数字为止,第一个人希望剩下的数字最小,第二个人希望数字最大,最终数字是多少? 思路: 贪心,第一个人每次取最大的,第二个人取最小的,最后就是中间值,直接排序即可. 代码: #include<bits/stdc++.h> using namespace std; ]; int main() { int n; cin >> n; ; i <=…
A:首先将p和q约分.容易发现相当于要求存在k满足bk mod q=0,也即b包含q的所有质因子.当然不能直接分解质因数,考虑每次给q除掉gcd(b,q),若能将q除至1则说明合法.但这个辣鸡题卡常,每求一次gcd都除干净就可以了. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorith…