Lightoj 1014 - Ifter Party
I have an Ifter party at the 5th day of Ramadan for the contestants. For this reason I have invited C contestants and arranged P piaju's (some kind of food, specially made for Ifter). Each contestant ate Q piaju's and L piaju's were left (L < Q).
Now you have to find the number of piaju's each contestant ate.
Input
Input starts with an integer T (≤ 325), denoting the number of test cases.
Each case contains two non-negative integers P and L (0 ≤ L < P < 231).
Output
For each case, print the case number and the number of possible integers in ascending order. If no such integer is found print 'impossible'.
简化问题,求一个数的所有因子。.....sqrt(n)
/* ***********************************************
Author :guanjun
Created Time :2016/6/18 22:38:57
File Name :1014.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
vector<ll>v;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int T;
ll p,l;
cin>>T;
for(int t=;t<=T;t++){
printf("Case %d: ",t);
v.clear();
scanf("%lld %lld",&p,&l);
ll n=p-l;
for(ll i=;i*i<=n;i++){
if(n%i==){
if(i>l)v.push_back(i);
if(n/i>l&&(i*i!=n))v.push_back(n/i);
}
}
sort(v.begin(),v.end());
int m=v.size();
for(int i=;i<m;i++){
printf("%lld%c",v[i],i==m-?:' ');
}
if(m==)puts("impossible");
}
return ;
}
Lightoj 1014 - Ifter Party的更多相关文章
- light oj 1014 - Ifter Party分解因子
1014 - Ifter Party I have an Ifter party at the 5th day of Ramadan for the contestants. For this r ...
- Ifter Party LightOJ - 1014(水题)
题意:有C个人,给P个食物,每人吃Q个,剩L个.然后给你P和L(Q>L),让你求Q的可能情况,如果有多种可能,从小到大输出:如果不存在,输出impossible 就是求写出公式 遍历c求P-L的 ...
- lightoj 1014
判断到根号n即可,另外使用dfs输出,不需要另开数组再排序. #include<cmath> #include<cstdio> int P, L, len, cnt; void ...
- lightoj刷题日记
提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...
- LightOJ 1236 - Pairs Forming LCM(素因子分解)
B - Pairs Forming LCM Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu ...
- LightOJ 1236 Pairs Forming LCM (LCM 唯一分解定理 + 素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1236 Pairs Forming LCM Time Limit:2000MS Memor ...
- Pairs Forming LCM (LightOJ - 1236)【简单数论】【质因数分解】【算术基本定理】(未完成)
Pairs Forming LCM (LightOJ - 1236)[简单数论][质因数分解][算术基本定理](未完成) 标签: 入门讲座题解 数论 题目描述 Find the result of t ...
- 1014: [JSOI2008]火星人prefix
1014: [JSOI2008]火星人prefix Time Limit: 10 Sec Memory Limit: 162 MB Description 火星人最近研究了一种操作:求一个字串两个后缀 ...
- 区间DP LightOJ 1422 Halloween Costumes
http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.c ...
随机推荐
- 论MySQL中如何代替Oracle中select into new_table from old_table
v_receipt warehouse_receipt%ROWTYPE;-- 这里创建表类型,v_receipt复刻了warehouse_receipt的类型(相当于拥有了所有相同的字 ...
- Java学习--异常处理及其应用类
异常是运行时在代码序列中引起的非正常状况,换句话说,异常是运行时错误.在不支持异常处理的计算机语言中,必须手动检查和处理错误----通常是通过使用错误代码,等等.这种方式既笨拙又麻烦.Java的异常处 ...
- Leetcode 315.计算右侧小于当前元素的个数
计算右侧小于当前元素的个数 给定一个整数数组 nums,按要求返回一个新数组 counts.数组 counts 有该性质: counts[i] 的值是 nums[i] 右侧小于 nums[i] 的元 ...
- 生物遗传学 整理人PYJ (恋_紫花地丁)
生物遗传学整理人PYJ (恋_紫花地丁) 高中生物唯一需要数学知识的就是遗传学的概率计算了.这里对简单的遗传学规律做一些总结. 目录: 1. 孟德尔第一定律(分离定律): 2. 孟 ...
- mybatis查询返回null解决方案
mybatis查询返回null解决方案: 问题:查询出的列与javabean中的字段名不一致. 解决方案: 1.将javabean中的字段改为和查询出的列名一致: 2.将sql加入as改变列名,和ja ...
- 获取当前日期的T-SQL语句
CONVERT(nvarchar(10),count_time,121): CONVERT为日期转换函数,一般就是在时间类型 (datetime,smalldatetime)与字符串类型(nchar, ...
- Java 实体-实体的映射框架
一.Object mapping 的技术分类: 运行期 反射调用set/get 或者是直接对成员变量赋值 . 该方式通过invoke执行赋值 *,实现时一般会采用beanutil, Javassist ...
- SpringBoot自定义Filter
SpringBoot自定义Filter SpringBoot自动添加了OrderedCharacterEncodingFilter和HiddenHttpMethodFilter,当然我们可以自定 义F ...
- 最大和(codevs 1648)
题目描述 Description N个数围成一圈,要求从中选择若干个连续的数(注意每个数最多只能选一次)加起来,问能形成的最大的和. 输入描述 Input Description 第一行输入N,表示数 ...
- 贪婪大陆(cogs 1008)
[题目描述] 面对蚂蚁们的疯狂进攻,小FF的Tower defense宣告失败……人类被蚂蚁们逼到了Greed Island上的一个海湾.现在,小FF的后方是一望无际的大海,前方是变异了的超级蚂蚁. ...