这道题可以暴力的一直按要求的方法去做,做1000000次还不能整除m就认为永远不能整除m了(m不超过100000,循环1000000次比较安全了已经).这种方法可以AC. 下面深入的分析一下到底循环多少次就可以确定结果:首先有这样一个规律:(a+b)%c=(a%c+b%c)%c,那么这样其实这道题每次就是2*a.官方题解说的好: Production will stops iff exists integer K ≥ 0 such a·2K is divisible by m. From thi…
题目地址:http://codeforces.com/contest/485 A题.Factory 模拟.判断是否出现循环,如果出现,肯定不可能. 代码: #include<cstdio> #include<stdbool.h> using namespace std; int main() { int a,m; ]={}; scanf("%d%d",&a,&m); while(true) { ){ printf("Yes\n"…
A. Factory 题意:给出a,m,第一天的总量为a,需要生产为a%m,第二天的总量为a+a%m,需要生产(a+a%m)%m 计算到哪一天a%m==0为止 自己做的时候,把i开到1000来循环就过了,后来搜题解发现这样过了是运气好 应该这样理解:a大于m的时候没有意义,当a%m重复出现的时候,说明出现了循环,终止计算. #include<iostream> #include<cstdio> #include<cstring> #include<algorith…
D. Multipliers 题目连接: http://codeforces.com/contest/615/problem/D Description Ayrat has number n, represented as it's prime factorization pi of size m, i.e. n = p1·p2·...·pm. Ayrat got secret information that that the product of all divisors of n take…
D. Kindergarten Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/484/D Description In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child wi…
B. Maximum Value Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/484/problem/B Description You are given a sequence a consisting of n integers. Find the maximum possible value of (integer remainder of ai divided by aj), whe…
A. Bits Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/484/problem/A Description Let's denote as the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries…
链接:http://codeforces.com/contest/484/problem/E 题意: 给你n个数的,每个数代表高度: 再给出m个询问,每次询问[l,r]区间内连续w个数的最大的最小值: 思路: 因为查询的到的值一定是输入的其中一个,那么我们可以二分答案,判断二分得到的答案是否符合,那么在这里我们就只需要找到某个数x,查询区间[l,r]有多少个连续的数大于x,这个操作只需要将高度从小到达排序,倒着插入主席树中,值设为1,那么只要维护有多少个连续的1(线段树区间合并的方法),就代表有…
http://codeforces.com/contest/484/problem/A 题意: 询问[a,b]中二进制位1最多且最小的数 贪心,假设开始每一位都是1 从高位i开始枚举, 如果当前数>b,且减去1<<i后仍>=a,就减1<<i 当当前数在[a,b]之间时,输出 因为从高位开始减,所以保证当前数是最小的 #include<cstdio> #include<iostream> using namespace std; typedef l…
http://codeforces.com/contest/484/problem/E 题意: 给出n个数,查询最大的在区间[l,r]内,长为w的子区间的最小值 第i棵线段树表示>=i的数 维护最长连续子区间 把数从大到小插入主席树 对于每个询问,二分x 在第x棵线段树中查,若最长连续子区间>=w,到代表更大的线段树中查 没有建第n+1棵线段树,导致前面节点的siz不对,WA了一次 #include<cstdio> #include<iostream> #include…