摘要:
简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxl 1005int p, w;char st[maxl];int f[30] ={ 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9 };int g[30] ={ 1, 2, 3, 1, 2, 3, 1, 2, 3, 阅读全文
posted @ 2011-09-13 21:20
undefined2024
阅读(105)
评论(0)
推荐(0)
摘要:
树状数组+二分View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 50005int n, m;char st[5];int ar[maxn];bool vis[maxn];int stk[maxn];int top;int lowb(int t){ return t &(-t);}void add(int i, int v){ for (; i < maxn 阅读全文
posted @ 2011-09-13 19:05
undefined2024
阅读(348)
评论(0)
推荐(0)
摘要:
简单分型题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 15int n;int power[maxn];bool is(int a, int p){ while (p >= 0) { if (a / power[p] == 1) return false; a %= power[p]; p--; } return true;}... 阅读全文
posted @ 2011-09-13 17:31
undefined2024
阅读(146)
评论(0)
推荐(0)
摘要:
简单二进制高精度,java做View Code import java.io.*;import java.util.*;import java.math.*;public class Main { static public void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int t = cin.nextInt(); for (int i = 0; i < t; i++) { ... 阅读全文
posted @ 2011-09-13 16:10
undefined2024
阅读(119)
评论(0)
推荐(0)
摘要:
题意:给出n,k,求k%1 + k%2 + …… + k%n;分析:当k/i = 1 时, k%i = k - i,随着i不断减小1,k-i每次减小1,即k%i每次减小1。当k/i=2时,i减小1,k%i减小2。我们要求k%i的和,可以划分为许多等差数列的和。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;long long n, k;int main(){ //freopen("t 阅读全文
posted @ 2011-09-13 16:01
undefined2024
阅读(263)
评论(0)
推荐(0)
摘要:
题意:给出m,k,求第k小的与m互质的数。分析:根据gcd的求法,我们可知,求最大公约数的第一步是用大数对小数取余。gcd(a,b)==gcd(a%b,b),进一步推出gcd(a,b)==gcd(a+b, b)。也就是说,当求出了1~m间与m互质的数之后,把这些数加上m就可以得到m~2m间的与m互质的数。而且m~2m间不会有某个与m互质的数被漏掉。因为如果m<=a<=2m,且gcd(a, m)==1,那么gcd(a - m, m)必然等于1。也就是必然有个在1~m间的数a-m,可以通过加m的方式得到a。所以与m互质的数是有周期性的。我们只需要求出第一个周期即可。View Code 阅读全文
posted @ 2011-09-13 10:05
undefined2024
阅读(574)
评论(0)
推荐(0)
摘要:
简单dpView Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 50char map[maxn][maxn];long long f[maxn][maxn];int n;void input(){ for (int i = 0; i < n; i++) scanf("%s", map[i]);}void work(){ memset(f, 0, si 阅读全文
posted @ 2011-09-13 09:21
undefined2024
阅读(125)
评论(0)
推荐(0)
摘要:
递推+高精度java做View Code import java.util.*;import java.math.*;import java.io.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); BigInteger f[] = new BigInteger[1005]; f[0] = new BigInteger("0"); ... 阅读全文
posted @ 2011-09-13 08:28
undefined2024
阅读(176)
评论(0)
推荐(0)