上一页 1 2 3 4 5 6 7 8 ··· 41 下一页

uestc 1722 吴神的表白

摘要: // 这题做的我好难过 不是因为没有思路 而是因为超数据类型范围的事// ax+by=c a,b,c>0// 那么该直线经过 1 2 4三个象限// 2 4 象限的第一整数解肯定是该象限最优解// 1 象限的话 x,y尽可能接近 那么解就在该 x与y接近的附近// 因为 第一象限的解 是 max(x,y) 所联立 x=y 与 ax+by=c =>x=c/(a+b) 枚举该点附近的 几个点就是最优解了// 也可以 求出 x0 y0特解后 利用 x0-b't=y0+a't 求出 x=x0-((x0-y0)/(a'+b')*b')// 这两种方法都 阅读全文
posted @ 2013-07-30 08:35 江财小子 阅读(185) 评论(0) 推荐(0) 编辑

uestc 1725 吴神数

摘要: // 筛选法// 先求出 sqrt(1#include #include #include #include #include #include using namespace std;#define MOD 1000000007#define maxn 1000010#define maxm 48010#define LL long longint pr[maxm];int p;void getP(){ int i,j; for(i=4;iB) break; for(j=(A-1+pr[i])/pr[i];j*pr[i]1){ ... 阅读全文
posted @ 2013-07-29 09:15 江财小子 阅读(146) 评论(0) 推荐(0) 编辑

uestc 1721 吴神,人类的希望

摘要: // 将n个相同的球放进m个盒子 盒子不为空的方法总数// dp[i][j] 表示i个盒子 j个球的方法总数// 递推关系 dp[i][j]=dp[i-1][j-1]+d[i][j-i]// a. i-1个盒子放j-1个球 第j个球放进第i个盒子中// b. i个盒子放了j-i个球 再放进i个球 每个盒子放一个// 注意 ans=ans+dp[i][n-k*i+i] 这里的 n-k*i+i // 加 i 的目的是为了 n-k*i+i>=i 这样就得到盒子不为空计数 #include #include #include #include #include #include #include 阅读全文
posted @ 2013-07-27 17:21 江财小子 阅读(193) 评论(0) 推荐(0) 编辑

uestc 1720无平方因子数

摘要: 求素数 然后容斥原理// n之内有平方因子的数的个数sum =n/(2^2) + n/(3^2)+……+n/(k^2) - n/(2^2 * 3^2)-……+…….// #pragma comment(linker, "/STACK:1024000000,1024000000")#include #include #include #include #include #include #include using namespace std;#define MOD 1000000007#define maxn 1000010#define maxm 1000010#defi 阅读全文
posted @ 2013-07-27 11:33 江财小子 阅读(490) 评论(0) 推荐(0) 编辑

hdu 4612 Warm up

摘要: // 题意是要求在加完一条边后 使得桥最小// 求桥 缩 边-连通分量 变成一颗树 然后求树的直径// 看到这题是思路非常明确的// 然后爆栈的问题一直困扰着我// 然后我发现ac的代码里面有 #pragma comment(linker, "/STACK:1024000000,1024000000")// 这个东西 今天无意中看到题解 然后说hdu栈太小 标程都跪了、// 我、、、、#pragma comment(linker, "/STACK:1024000000,1024000000")#include #include #include #inc 阅读全文
posted @ 2013-07-27 09:11 江财小子 阅读(378) 评论(0) 推荐(0) 编辑

hdu 4614 Vases and Flowers

摘要: // 线段树// 节点保存 区间长度 和 区间的 空闲位置// 好久没写线段树了 不过除了第一次提交是数组开小导致访问非法内存了外 1Y// 我写了好多函数 分别求最左区间 最右区间 区间和 区间覆盖// 不过速度还好 去看了下排名 居然第三 O(∩_∩)O哈! 不过估计不久后就会被刷下去吧#include #include #include #include #include #include #include using namespace std;#define maxm 100010#define maxn 50010#define LL __int64#define lson l,m 阅读全文
posted @ 2013-07-25 20:30 江财小子 阅读(317) 评论(0) 推荐(0) 编辑

hdu 1299 Diophantus of Alexandria

摘要: 1/x + 1/y = 1/n 1n 那么设 x=n+m 那么 1/y= 1/n - 1/(n+m)// 1/y = m/(n*n+n*m) 所以满足 n*n|m 的m都是可以的 // 问题转化成求n*n 的约数个数 因数分解 然后用求约数个数公式// 最后答案记得 除 2 因为重复算了#include #include #include #include #include #include #include using namespace std;#define maxm 100010// #define maxn 47010#define LL __int64int prim[470... 阅读全文
posted @ 2013-07-25 17:19 江财小子 阅读(200) 评论(0) 推荐(0) 编辑

hdu 1211 RSA

摘要: // 表示题目意思我是理解了蛮久 英语太水了 //首先这是解密公式 m=c^d mod n// 给你 p q e 然后 n=p*q fn=(p-1)*(q-1)// 给你 e,根据公式 e*d mod fn =1 求出 d // 然后有 L个数据要解密// 算法:// 扩展欧几里得 :求 d// 快速幂运算 :解密#include #include #include #include #include #include #include using namespace std;#define maxm 100010#define maxn 1000110#define LL __int64.. 阅读全文
posted @ 2013-07-25 15:58 江财小子 阅读(402) 评论(0) 推荐(0) 编辑

poj 2773 Happy 2006

摘要: // 题意 :给你两个数 m(10^6),k(10^8) 求第k个和m互质的数是什么这题主要需要知道这样的结论gcd(x,n)=1 gcd(x+n,n)=1证明 假设 gcd(x,n)=1 gcd(x+n,n)!=1 令 a=n+x b=n 设 gcd(a,b)=k>1 那么有 a=Ak b=Bk x+Bk=Ak => x=(A-B)k k是n的因子 那么 x=(A-B)k 显然不成立 因为x不可能含有因子k(因为x,n互质); 所以假设不成立 那么这题剩下的就算求 比m小 与m互质的数就可以了#include #include #include #i... 阅读全文
posted @ 2013-07-25 11:01 江财小子 阅读(191) 评论(0) 推荐(0) 编辑

hdu 2204 Eddy's爱好

摘要: // 一个整数N,110^18 所以最多只取3个素数#include #include #include #include #include #include #include using namespace std;#define maxm 100010#define maxn 1000110int prim[110]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59};// 17个int main(){ int i,j,ct,mid; int rc[5]; __int64 n,m,ans,tp; while(scanf(... 阅读全文
posted @ 2013-07-25 10:10 江财小子 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 41 下一页