Codeforces Round #433 Div. 1】的更多相关文章

题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int gcd(int a,int b){return b?gcd(b…
A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足条件的a和b,输出a/b最大的a和b. 题目思路:首先a+b=n,那么暴力枚举i和n-i,且gcd(i,n-i)==1,由于i越大是n-i越小,则a/b的值越大. 代码: //Author: xiaowuga #include <bits/stdc++.h> using namespace std…
A:显然从大到小排序后贪心放在第一个能放的位置即可.并查集维护. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long #define N 300010 char getc(){char c=…
题意:几个人要去一个城市k天,现给出各航班的日期和花费,让这n个人能相会k天的最小花费? 用数组arr1[i]记录在第i天人到齐的最小花费.arr2[i]记录第i天之后才有人开始走的最小花费.然后取arr1[i]+arr2[i+k+1]的最小值. //#pragma comment(linker,"/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<stri…
D. Jury Meeting time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet toge…
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively num…
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day. Metropolis airport is the main transport hub of…
Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartments that are numbered from 1 to nand are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can alrea…
Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction  is called proper iff its numerator is smaller than its denominator (a < b) and that the fraction is called irreducible if its numerator…
[链接]h在这里写链接 [题意] 有n个人,它们都要在某一时刻开始,全都到达0位置,然后维持最少k个时间单位,然后再全都回到原来的位置; 第i个人初始的位置是i. 且一共有m班航班. 每一班航班,要么是从0出来的,要么是进入0的,且航班起飞的时间为di,出发地为fi,目的地为ti,花费为ci; (航班当天到); 到或起飞的那一天不算k天中的一天. 问你每个人到达0,然后又回到各自位置的最小花费. [题解] 考虑每个航班起飞的时间,把每个航班的信息加入到di时刻上. vector <pair <…