摘要:
这类问题一般都有固定的公式,告诉大家一个技巧:二维的一般是f(x)=a*x^2+b*x+c,三维的一般是f(x)=a*x^3+b*x^2+c*x+d. 用带定系数法求出各个系数就行了。http://acm.hdu.edu.cn/showproblem.php?pid=1290View Code #include"iostream"using namespace std;int main(){ int n; while(cin>>n) { cout<<(n*n*n+5*n+6)/6<<endl; } return 0;} 阅读全文
posted @ 2011-04-02 21:18
聊聊IT那些事
阅读(567)
评论(0)
推荐(0)
摘要:
刚开始用了几次gcd(),结果n次tle, 最后用了筛选法,终于a了,效率提高不少啊!http://acm.hdu.edu.cn/showproblem.php?pid=1286View Code #include"iostream"using namespace std;int main(){ int n,a,i,j,count; int b[32768]; cin>>n; while(n--) { cin>>a; memset(b,0,sizeof(b)); for(i=2;i<=a;i++) { if(a%i==0&&b[ 阅读全文
posted @ 2011-04-02 20:51
聊聊IT那些事
阅读(267)
评论(0)
推荐(0)
摘要:
:::---> a = b ^ c —-> c = a ^ b b = a ^ c,就是异或递推的关系。http://acm.hdu.edu.cn/showproblem.php?pid=1287View Code // a = b ^ c —-> c = a ^ b b = a ^ c#include"iostream"#include"math.h"using namespace std;int main(){ int n,i; int a[1000]; char ch; while(cin>>n) { for(i=0; 阅读全文
posted @ 2011-04-02 19:45
聊聊IT那些事
阅读(226)
评论(0)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1065错了n次了,让所有的水题汗颜啊!View Code #include"iostream"using namespace std;#define pi 3.1415926//3.1415927(wrong)int main(){ int n; double a,b,sum; cin>>n; int i=0; while(n--) { cin>>a>>b; sum=pi*(a*a+b*b)/2; int x=(int)(sum/50)+1; //(in 阅读全文
posted @ 2011-04-02 17:49
聊聊IT那些事
阅读(396)
评论(0)
推荐(0)