和2140只是格式不同(还有一个不同之处是k>= 2)。
thestoryofsnow | 2853 | Accepted | 160K | 0MS | C++ | 762B |
/*
ID: thestor1
LANG: C++
TASK: poj2853
*/
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <limits>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cassert>
using namespace std;
int ways(int N)
{
const int N2 = N * 2;
const int UPPER = sqrt((double)N2);
int cnt = 0;
for (int k = 2; k <= UPPER; ++k)
{
if (N2 % k == 0 && (N2 / k + 1 - k) % 2 == 0)
{
cnt++;
}
}
return cnt;
}
int main()
{
int T;
scanf("%d", &T);
for (int t = 0; t < T; ++t)
{
int no, N;
scanf("%d%d", &no, &N);
printf("%d %d\n", no, ways(N));
}
return 0;
}