Ifter Party LightOJ - 1014(水题)
题意:有C个人,给P个食物,每人吃Q个,剩L个。然后给你P和L(Q>L),让你求Q的可能情况,如果有多种可能,从小到大输出;如果不存在,输出impossible
就是求写出公式 遍历c求P-L的因子就出来了
用set 正好
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
set<LL> s;
int main()
{
int T, kase = ;
scanf("%d",&T);
while(T--)
{
s.clear();
LL p, l;
scanf("%lld%lld",&p,&l);
for(LL i=; i * i<=p-l; i++)
if((p-l)%i == )
{
if(i > l)
s.insert(i);
if((p-l)/i > l)
s.insert((p-l)/i);
} printf("Case %d:",++kase);
if(s.empty())
printf(" impossible");
else
for(set<LL>::iterator it = s.begin(); it!=s.end(); it++)
{
printf(" ");
printf("%lld",*it);
}
printf("\n");
} return ;
}
题意:有C个人,给P个食物,每人吃Q个,剩L个。然后给你P和L(Q>L),让你求Q的可能情况,如果有多种可能,从小到大输出;如果不存在,输出impossible
Ifter Party LightOJ - 1014(水题)的更多相关文章
- lightoj 1010 (水题,找规律)
lightoj 1010 Knights in Chessboard 链接:http://lightoj.com/volume_showproblem.php?problem=1010 题意:国际象棋 ...
- LightOJ 1166 Old Sorting 置换群 或 贪心 水题
LINK 题意:给出1~n数字的排列,求变为递增有序的最小交换次数 思路:水题.数据给的很小怎么搞都可以.由于坐标和数字都是1~n,所以我使用置换群求循环节个数和长度的方法. /** @Date : ...
- LightOJ 1065 - Number Sequence 矩阵快速幂水题
http://www.lightoj.com/volume_showproblem.php?problem=1065 题意:给出递推式f(0) = a, f(1) = b, f(n) = f(n - ...
- Lightoj 1112 - Curious Robin Hood 【单点改动 + 单点、 区间查询】【树状数组 水题】
1112 - Curious Robin Hood PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 64 MB ...
- hdu 1012:u Calculate e(数学题,水题)
u Calculate e Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- D - 楼下水题(kmp+Manacher)
D - 楼下水题 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Statu ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
随机推荐
- python002
1.万恶的”+“号字符串拼接 字符串中的连接符+”会开辟一个新的空间,多一个“+“就会多开辟一个空间,影响性能 2.字符串格式化 ”%S“ :字符类型 ”%D“ ”数字类型 ...
- gym100676 [小熊骑士限定]2015 ACM Arabella Collegiate Programming Contest
Kuma Rider久违的第二场训练,这场很水,又在vj的榜单上看到第一场的大哥了,2小时ak,大哥牛啤! A.水 #include<cstdio> #include<iostrea ...
- numastat命令详解
基础命令学习目录 作者:[吴业亮]博客:http://blog.csdn.net/wylfengyujiancheng一.系统架构的演进从SMP到NUMA1.SMP(Symmetric Multi-P ...
- 【quickhybrid】JS端的项目实现
前言 API实现阶段之JS端的实现,重点描述这个项目的JS端都有些什么内容,是如何实现的. 不同于一般混合框架的只包含JSBridge部分的前端实现,本框架的前端实现包括JSBridge部分.多平台支 ...
- It isn't possible to write into a document from an asynchronously-loaded
It isn't possible to write into a document from an asynchronously-loaded 今天遇到了一个问题: 通过document.wri ...
- Daily Scrumming* 2015.10.29(Day 10)
一.总体情况总结 二.今明两天任务表 Member Today’s Task Tomorrow’s Task 江昊 了解微信API,与社团服务平台创业公司嗨社团创始人沟通,了解其平台运营方案与商业模式 ...
- 20135316王剑桥 linux第六周课实验笔记
6.存储器层次结构 6.1存储技术 1.如果你的程序需要的数据是存储在CPU寄存器中的,那么在执行期间,在零个周期内就能访问到它们.如果存储在高速缓冲中,需要1-10个周期.如果存储在主存中,需要50 ...
- vmware_vcenter_api
VMware Vcenter_API 介绍 本文主要通过调用Vcenter_API,获取其中的数据中心,集群,主机,网络,存储,虚拟机信息. 开发语言 python 使用官方sdk pyvmomi 文 ...
- golang数据类型转换
int--string //string到int value_int,err:=strconv.Atoi(string) //int到string str:=strconv.Itoa(value_in ...
- Java面试&编写程序:使子线程循环10次,紧接着主线程循环100次,来回50次
package com.cwcec.test; public class TraditionalThreadCommunication { /** * @param args */ public st ...