2012年5月2日

[TLE] POJ 1730 Perfect Pth Powers

摘要: 给出一个32位整型数 n,形如 n = x^p 的最大的 p;质因数分解;TLE,DISCUSS 中有的用枚举做的(要考虑浮点数精度问题),但是质因数分解应该也可以啊,为什么老是TLE?求大牛指点。# include <stdio.h># include <math.h>int gcd(int a, int b){return !b ? a:gcd(b, a%b);}int m;char t[60005];int p[10005];void solve(long long int n);void build_ptable(void);int main(){ long l 阅读全文

posted @ 2012-05-02 22:02 getgoing 阅读(243) 评论(0) 推荐(0) 编辑

POJ 2262 Goldbach's Conjecture

摘要: 在 1000000 以内验证哥德巴赫猜想:筛法求素数;为了减少空间,可能要用素数定理,但这道题空间足够了;1WA,太着急了没注意到输入为 0 时结束。# include <stdio.h># define MAXN 1000000int m;int ptable[MAXN+1], p[MAXN/4];void build_ptable(void);void solve(int n);int main(){ int n; build_ptable(); while (~scanf("%d", &n) && n) solve(n); r... 阅读全文

posted @ 2012-05-02 15:29 getgoing 阅读(276) 评论(0) 推荐(0) 编辑

POJ 2551 Ones

摘要: 题目描述:Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n?a multiple of n 的意思是某一个数与 n 的积(吧?)开始我愣是没读懂题,一搜都说是水题,没看别人的题解,自己想了两种方法:1. 试因子法:每次选取一个0-9的数字使 阅读全文

posted @ 2012-05-02 13:04 getgoing 阅读(407) 评论(0) 推荐(0) 编辑

导航