POJ 2853
#include<iostream> #include<stdio.h> #include<vector> #include<math.h> #include<algorithm> #define FOR for #define M 10009 using namespace std; int main() { //freopen("acm.acm","r",stdin); unsigned sum; unsigned num; unsigned ans; unsigned pos; unsigned pos1; int time; int tem; int i; cin>>time; while(time --) { ans = 0; cin>>tem>>num; for(i = 1; i < sqrt(long double(num*2)); ++ i) { if((2 * num % i == 0) && (i + 2 * num / i) % 2 != 0) { ++ ans; } } cout<<tem<<" "<<--ans<<endl; } } /* 需求出这个不定方程的解数即可。显然2 * i + j - 1 > j,于是j < sqrt(2 * n), 方程有解的条件是(2 * n % j == 0) && (j + 2 * n / j) % 2 != 0 有多少个j满足条件就有多少个解,编程实现就很简单了 */