UVA 617 - Nonstop Travel(数论+暴力枚举)
题目链接:617 - Nonstop Travel
#include <stdio.h>
#include <string.h>
#include <math.h>
const double esp = 1e-6;
int n, vis[105];
struct D {
double l;
int g, y, r;
void scanf_() {
scanf("%lf%d%d%d", &l, &g, &y, &r);
}
} d[10]; bool judge(int vv) {
double v = vv * 1.0 / 3600;
for (int i = 0; i < n; i++) {
double t = d[i].l / v;
int dd = (int)t / (d[i].g + d[i].y + d[i].r);
t -= dd * 1.0 * (d[i].g + d[i].y + d[i].r);
if (t - 1.0 * (d[i].g + d[i].y) > -esp)
return false;
}
return true;
} void print() {
int flag = 1, i = 30;
for (; i <= 60; i++) {
if (vis[i]) {
printf("%d", i);
flag = 0;
break;
}
}
i++;
for (; i <= 60; i++) {
if (vis[i] && vis[i - 1] == 0)
printf(", %d", i);
else if (vis[i] && vis[i - 1] && vis[i + 1] == 0)
printf("-%d", i);
}
if (flag) printf("No acceptable speeds.");
printf("\n");
} int main() {
int cas = 0;
while (~scanf("%d", &n) && n != -1) {
for (int i = 0; i < n; i++)
d[i].scanf_();
memset(vis, 0, sizeof(vis));
for (int i = 30; i <= 60; i++) {
if (judge(i)) vis[i] = 1;
}
printf("Case %d: ", ++cas);
print();
}
return 0;
}
UVA 617 - Nonstop Travel(数论+暴力枚举)的更多相关文章
- UVA - 11464 Even Parity 【暴力枚举】
题意 给出一个 01 二维方阵 可以将里面的 0 改成1 但是 不能够 将 1 改成 0 然后这个方阵 会对应另外一个 方阵 另外一个方阵当中的元素 为 上 下 左 右 四个元素(如果存在)的和 要求 ...
- UVA 10976 Fractions Again?!【暴力枚举/注意推导下/分子分母分开保存】
[题意]:给你一个数k,求所有使得1/k = 1/x + 1/y成立的x≥y的整数对. [分析]:枚举所有在区间[k+1, 2k]上的 y 即可,当 1/k - 1/y 的结果分子为1即为一组解. [ ...
- UVa 1354 Mobile Computing[暴力枚举]
**1354 Mobile Computing** There is a mysterious planet called Yaen, whose space is 2-dimensional. Th ...
- UVa 341 - Non-Stop Travel
题目大意:给一个地区的地图,上面有若干路口,每个路口因为红灯的缘故要耽误一些时间,给出起点和终点,找出最短路径使得耽误时间最短. 单源最短路问题,Dijkstra算法.同时还要打印路径. #inclu ...
- UVA.12716 GCD XOR (暴力枚举 数论GCD)
UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...
- UVA 10012 How Big Is It?(暴力枚举)
How Big Is It? Ian's going to California, and he has to pack his things, including his collection ...
- uva 11088 暴力枚举子集/状压dp
https://vjudge.net/problem/UVA-11088 对于每一种子集的情况暴力枚举最后一个三人小组取最大的一种情况即可,我提前把三个人的子集情况给筛出来了. 即 f[S]=MAX{ ...
- 紫书 例题 10-2 UVa 12169 (暴力枚举)
就是暴力枚举a, b然后和题目给的数据比较就ok了. 刘汝佳这道题的讲解有点迷,书上讲有x1和a可以算出x2, 但是很明显x2 = (a * x1 +b) 没有b怎么算x2?然后我就思考了很久,最后去 ...
- UVA 11754 - Code Feat(数论)
UVA 11754 - Code Feat 题目链接 题意:给定一个c个x, y1,y2,y3..yk形式,前s小的答案满足s % x在集合y1, y2, y3 ... yk中 思路:LRJ大白例题, ...
随机推荐
- Android的CheckBox(多选框)
1.布局文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:t ...
- bind 简单配置dns
一. 安装apt-get install bind9 apt-get install bind9-host dnsutils apt-get install bind9-doc 二.修改本机配置我们要 ...
- python delete数据
#!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2017/11/24 0:27 # @Author : lijunjiang # @Fil ...
- 在windows系统上word转pdf
一.前言:我在做文件转换过程中遇到的一些坑,在这里记录下,因为项目需求,需要使用html转pdf,由于itext转换质量问题(一些Css属性不起作用),导致只能通过word文件作为跳板来转换到pdf文 ...
- J.U.C并发框架源码阅读(十六)FutureTask
基于版本jdk1.7.0_80 java.util.concurrent.FutureTask 代码如下 /* * ORACLE PROPRIETARY/CONFIDENTIAL. Use is su ...
- [Math Review] Statistics Basic: Sampling Distribution
Inferential Statistics Generalizing from a sample to a population that involves determining how far ...
- SpringBoot动态数据源
1.原理图 2.创建枚举类 /** * 存数据源key值 */ public enum DataSourceKey { master,salve,migration } 3.创建自定义注解类 /** ...
- Guess Number Higher or Lower II -- LeetCode
We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gues ...
- [BZOJ5110]Yazid的新生舞会
题目大意: 给你一个长度为$n(n\leq 5\times 10^5)$的序列$A_{1\sim n}$.求满足区间众数在区间内出现次数严格大于$\lfloor\frac{r-l+1}{2}\rflo ...
- 【java】java反射 Field类的研究使用
java反射 Field类的研究使用 user.getClass().getFields() 和 user.getClass().getDeclaredFields(); 的区别是什么?