【数论,水题】UVa 10127 - Ones】的更多相关文章

  Three Families  Three families share a garden. They usually clean the garden together at the end of each week, but last week, family C was on holiday, so family A spent 5 hours, family B spent 4 hours and had everything done. After coming back, fam…
The first place of 2^n Problem Description LMY and YY are mathematics and number theory lovers. They like to find and solve interesting mathematic problems together. One day LMY calculates 2n one by one, n=0, 1, 2,- and writes the results on a sheet…
http://poj.org/problem?id=1061 傻逼题不多说 (x+km) - (y+kn) = dL 求k 令b = n-m ; a = x - y ; 化成模线性方程一般式 : Lx+by=a 再除gcd化简成最简形式 使得L,b互素 (即构造 L'x+b'y =1) 求Ex_GCD得到 y * a 就是最后的答案...还是一样要化成正整数形式 pair<LL,LL> ex_gcd(LL a,LL b){ ) ,); pair<LL,LL> t = ex_gcd(…
There is a war and it doesn't look very promising for your country. Now it's time to act. You have a commando squad at your disposal and planning an ambush on an important enemy camp located nearby. You have N soldiers in your squad. In your master-p…
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predators, the geese population was out o…
反演一下可以得到$b_i=\sum\limits_{d=1}^i{\mu(i)(\lfloor \frac{i}{d} \rfloor})^n$ 整除分块的话会T, 可以维护一个差分, 优化到$O(nlogn+klogk)$ #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map>…
http://acm.hdu.edu.cn/showproblem.php?pid=1576 写了个ex_gcd的模板...太蠢导致推了很久的公式 这里推导一下: 因为 1 = BX + 9973Y        ----------------① 且 n = Bk - floor(A/9973) * 9973      ----------------② ①*n即    n = BnX + nY * 9973 那么 k = nX k = A/B ...而k%9973为所求 (n*X)%9973…
题目链接 题意:给你一个数n,问最少有多少个1构成的“1”串(1,11,...)能整除n; 比如:111能被3整除: 111111能被7整除:... 作为水货觉得只要自己能1A的都是水题=. = #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> using namespace std; ; int main() { int n, p[maxn]; while(~scan…
UVa 489 题目大意:计算机给定一个单词让你猜,你猜一个字母,若单词中存在你猜测的字母,则会显示出来,否则算出错, 你最多只能出错7次(第6次错还能继续猜,第7次错就算你失败),另注意猜一个已经猜过的单词也算出错, 给定计算机的单词以及猜测序列,判断玩家赢了(You win).输了(You lose).放弃了(You chickened out) /* UVa 489 HangmanJudge --- 水题 */ #include <cstdio> #include <cstring…
UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要,可以分别统计两个字符串中的各个字母出现的次数,得到两个cnt[26]数组, 又由于可以进行映射,则可以直接对两个数组进行排序后判断是否相等(相当于原来相等的值的两个地方做映射) /* UVa 1339 Ancient Cipher --- 水题 */ #include <cstdio> #incl…