1014 - Ifter Party
来源:互联网 发布:jsp 获取客户端mac 编辑:程序博客网 时间:2024/05/16 18:22
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'.
Sample Input
Output for Sample Input
4
10 0
13 2
300 98
1000 997
Case 1: 1 2 5 10
Case 2: 11
Case 3: 101 202
Case 4: impossible
SPECIAL THANKS: JANE ALAM JAN (DESCRIPTION, SOLUTION, DATASET)
求p-l大于l的因子
#include <cstdio>#include <cstring>#include <algorithm>#include <queue>#include <map>#include <set>#include <stack>#include <cmath>#include <string>#include <iostream>#include <vector>#define LL long long#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn=1<<30;const int SIZE=1e5+10;set<int>st;void get_fac(int x,int l){ st.clear(); for(int i=1;i<=(int)sqrt((double)x);i++){ if(x%i==0){ if(i>l)st.insert(i); if(x/i>l)st.insert(x/i); } }}int main(){ int T,x; scanf("%d",&T); for(int cas=1;cas<=T;cas++){ int p,l; scanf("%d%d",&p,&l); x=p-l; get_fac(x,l); printf("Case %d: ",cas); if(st.empty()){ printf("impossible\n"); continue; } set<int>::iterator it=st.begin(); printf("%d",*it); for(it++;it!=st.end();it++){ printf(" %d",*it); } printf("\n"); } return 0;}
- LightOJ 1014 Ifter Party
- 1014 - Ifter Party
- 1014 - Ifter Party
- LightOJ-1014-Ifter Party
- Light OJ 1014 - Ifter Party
- Light oj 1014 - Ifter Party
- LightOJ 1014 - Ifter Party (**求因子)
- LightOJ 1014 Ifter Party 分解因子
- LightOJ1014 Ifter Party
- Ifter Party LightOJ
- Light OJ 1014 Ifter Party [因子分解]【数论】
- Party
- Party
- Party
- Party
- Party
- CodeForces Gym 100646D Party Party Party
- Anniversary party
- acm_专题2_1001
- java怎么循环遍历ArrayList
- bzoj4514 数字配对 费用流
- 基础算法学习之穷举
- ios事件的通知方法
- 1014 - Ifter Party
- hdu 4296 Buildings
- 写在省选之前
- 常见捕获异常的场景
- Windows7系统下安装OpenSSL攻略
- 基础算法-快速排序
- 发布自己的网站--------IIS
- 查询两个表的数据 union
- LightOJ 1422 Halloween Costumes (区间dp)