zrq495
www.zrq495.com
摘要: 2009=287*7=41*49=41*7*7。所以当n>=41时,n!%2009=0。n<41时,用公式:(a*b)%c = ((a%c) * (b%c)) % c。代码如下: 1 #include<iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 long long n, i ,s; 8 while(cin >> n) 9 {10 if (n == 0)11 {12 cout << "1" << endl;13 conti... 阅读全文
posted @ 2012-08-04 21:33 zrq495 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 并查集简单应用。和HDU 1232 一样。代码如下: 1 #include<iostream> 2 3 using namespace std; 4 5 int set[1010]; 6 int cnt; 7 8 int find(int a) 9 {10 int x=a;11 while(x != set[x])12 x=set[x];13 return x;14 }15 16 void merge(int a, int b)17 {18 int x=find(a);19 int y=find(b);20 if (x!=y... 阅读全文
posted @ 2012-08-04 21:19 zrq495 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题意:给出三个点,求抛物线和直线所围成的面积。设抛物线的方程为y=a(x-h)^2+k, 直线方程为y=dx+e; 所以h和k分别是顶点的横纵坐标,即h=x1,k=y1.把(x2,y2)或(x3,y3)代入抛物线方程求出 a,代入直线方程求出d和e 。(见代码)然后分别对它们积分,求出面积,相减即可。代码如下: 1 #include<iostream> 2 #include<cstdio> 3 4 using namespace std; 5 6 int main() 7 { 8 int T; 9 double s1, s2;10 double a, h, k, e.. 阅读全文
posted @ 2012-08-04 21:11 zrq495 阅读(160) 评论(0) 推荐(0) 编辑