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 ...
随机推荐
- react组件父传子
react组件父传子,子组件使用父组件的数据,用props import React, { Component } from 'react'; class App extends Component ...
- SSH三大框架的工作原理
Hibernate工作原理 原理:1.通过Configuration().configure();读取并解析hibernate.cfg.xml配置文件2.由hibernate.cfg.xml中的< ...
- Everything的简单使用
1.Everythings下载地址: http://www.voidtools.com/ 下载完后直接解压,运行everything.exe即可打开使用: 2.基本设置 (1)去除不需要搜索的文件夹: ...
- js,javascript,打印对象,object
function writeObj(obj){ var description = ""; for(var i in obj){ var property=obj[i]; desc ...
- java 块语句 和引用类型
1.java中存在块语句,块语句分为四种 1.静态块 2.普通块 3.构造块 4.同步块 静态块的执行时机是在class文件装载的时候;静态块只会执行一次, 多个静态块的时候,按出现顺序执行,存放类的 ...
- Mac 下netstat和linux下不一样
Linux's netstat command options and OS X(/BSD)'s have almost nothing to do with each other. Of the o ...
- common.php
<?php /** * */ class Common { if(!function_exists('is_php')) { function is_php($version = '5.0.0' ...
- 主题模型之潜在语义分析(Latent Semantic Analysis)
主题模型(Topic Models)是一套试图在大量文档中发现潜在主题结构的机器学习模型,主题模型通过分析文本中的词来发现文档中的主题.主题之间的联系方式和主题的发展.通过主题模型可以使我们组织和总结 ...
- Scala_特质
特质 特质概述 Java中提供了接口,允许一个类实现任意数量的接口 在Scala中没有接口的概念,而是提供了“特质(trait) ”,它不仅实 现了接口的功能,还具备了很多其他的特性 Scala的特质 ...
- hbase首次导入大批次的数据成功!
本次主要是采用hbase自带的importtsv工具来导入.首先要把数据文件上传到hdfs上,然后导入hbase表格.该导入方式只支持.tsv数据文件的导入. 导入流程: 1.下载数据.我们在本文中将 ...