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满足条件就有多少个解,编程实现就很简单了
*/
POJ 2853的更多相关文章
- POJ 2853 Sequence Sum Possibilities
Sequence Sum Possibilities Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5537 Accep ...
- Poj 2853,2140 Sequence Sum Possibilities(因式分解)
一.Description Most positive integers may be written as a sum of a sequence of at least two consecuti ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
随机推荐
- 2018.11.06 bzoj2287: 【POJ Challenge】消失之物(背包)
传送门 先假设所有物品都能用,做01背包求出方案数. 然后枚举每个点,分类讨论扣掉它对答案的贡献. 代码: #include<bits/stdc++.h> using namespace ...
- centos 7 安装 python3.6 python3 安装步骤以及pip pip3安装挂载
首先去python官网下载python3的源码包,网址:https://www.python.org/ 或者直接wget下载 wget https://www.python.org/ftp/pytho ...
- shell脚本之正则表达式
具体参考: www.jb51.net/tools/shell_regex.html 正则表达式常用于grep AWK 等工具中
- 好文推荐系列-------(5)js模块化编程
本文主要来源于阮一峰的<Javascript模块化编程>系列文章整合,原文地址:http://www.ruanyifeng.com/blog/2012/10/javascript_modu ...
- POJ2431--Expedition(优先队列)
Description A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Bein ...
- C语言中:static与extern对变量和函数的作用
1.两者对全局变量 static对全局变量,表示定义一个内部变量 extern对全局变量,表示声明一个外部变量 说明: 1.内部变量:定义的变量只能在本文件中访问,不能被其他文件访问. 2.不同文件中 ...
- POJ 1191棋盘分割问题
棋盘分割问题 题目大意,将一个棋盘分割成k-1个矩形,每个矩形都对应一个权值,让所有的权值最小求分法 很像区间DP,但是也不能说就是 我们只要想好了一个怎么变成两个,剩下的就好了,但是怎么变,就是变化 ...
- 学习JavaScript计划
1.首先根据视频做小例子 2.每天记录到博客 3.这次坚持把这个学完,并完成接口测试界面的编写
- [logic]逻辑整理
圈子详情页面: 1.加入圈子(*) 1.已登录,直接添加 2.未登录,登陆框 2.发表新帖(*) 1.已登录,直接跳转 2.未登录, ...
- 应该知道的Linux技巧【转】
这篇文章来源于Quroa的一个问答<What are some time-saving tips that every Linux user should know?>—— Linux用户 ...