2012年3月27日

sicily 1209. Sequence Sum Possibi

摘要: // 给出m,求由至少两个元素组成的等差数列的和恰好等于m,有多少种组合可能性// 比如 6 = 1 + 2 + 3 , 9 = 4 + 5 = 2 + 3 + 4 , 则答案是 1 2// 参照 sicily 1218 纪念邮票#include<iostream> #include<stdio.h>using namespace std;int main(){ int cases; cin>>cases; while(cases--) { int n,m,res=0; cin>>n>>m; ... 阅读全文

posted @ 2012-03-27 13:08 sysu_mjc 阅读(457) 评论(0) 推荐(0) 编辑

sicily 1218. 纪念邮票

摘要: // 题意: 给出n,m,求出 等差数列: a+(a+1)+...+(b-1)+b=m 有多少种(a,b)组合可能性, 其中a<=b<=n #include<iostream>#include <stdio.h>#include<map>using namespace std;int main(){ int n,m; map<int ,int> col; cin>>n>>m; int a,c; //设a,b间距离为c,即 c=b-a,所以 a+..+b=(a+b)(b-a+1)/2=(2a+c)(c+1)/2= 阅读全文

posted @ 2012-03-27 13:02 sysu_mjc 阅读(264) 评论(0) 推荐(0) 编辑

导航