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 ...
随机推荐
- js监听微信、支付宝返回,后退、上一页按钮事件
$(function(){ pushHistory(); window.addEventListener("popstate", function(e) { alert(" ...
- 假期训练八(poj-2965递归+枚举,hdu-2149,poj-2368巴什博奕)
题目一(poj-2965):传送门 思路:递归+枚举,遍历每一种情况,然后找出最小步骤的结果,与poj-1753类似. #include<iostream> #include<cst ...
- 菜品识别 API调用
#get_access_token.py #获取access_token 1 import requests def GetToken(API_KEY,SECRET_KEY): url = 'http ...
- C++IO cin
cin cin.get() 每次只读缓冲区一个字符,不能接收空格 cin.getline() 读缓冲区一行,能够接收空格 cin.ignore(2) 忽略缓冲器2个字节 int i = cin.pee ...
- Clion 教程书写Hello World,C语言开发;Clion 的C语言开发
一.编译器安装 二.项目搭建 1.新建项目 2.项目类型选择(双红圈是项目名称,可以修改) 3.点击create,自动生成项目. 4.运行项目
- UVa 1610 Party Games(思维)
题意: 给出一系列字符串,构造出一个最短字符串(可以不在集合中)大于等于其中的一半,小于另一半. 析:首先找出中间的两个字符串,然后暴力找出最短的字符串,满足题意. 代码如下: #include &l ...
- keepalive主从上同时出现VIP,且均无法消失
低版本bug 双主架构中,keepalived日志出现: more /var/log/messageOct 9 03:16:22 mysql-dzg-60-148 Keepalived_vrrp[85 ...
- MFC载入BMP图片
两步 hBitmap = (HBITMAP)LoadImage(NULL,fullPathName,IMAGE_BITMAP,120,120,LR_LOADFROMFILE);//载入图片 m_pic ...
- Windows下Django环境搭建
总体示意图如下: Windows下搭建Django环境 1.安装Python版本 2.安装pip工具,一般Python安装都会自动会有这个,在你python安装命令下Scripts文件夹下 3.dj ...
- pycharm的注册码,所有版本
77751S0VBA-eyJsaWNlbnNlSWQiOiI3Nzc1MVMwVkJBIiwibGljZW5zZWVOYW1lIjoi5b285bK4IHNvZnR3YXJlMiIsImFzc2lnb ...