codeforce round #467(div.2)
A. Olympiad
给出n个数,让你找出有几个非零并且不重复的数
所以用stl的set
//#define debug
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#define pb push_back
using namespace std;
typedef long long ll;
pair<ll,ll>PLL;
pair<int,ll>Pil;
const ll INF = 0x3f3f3f3f;
const double inf=1e8+100;
const ll maxn =1e5+100;
const int N = 1e4+10;
const ll mod=1000007;
int n,a[maxn];
set<int>s;
set<int>::iterator it;
void solve() {
int i,j,t=1;
// cin>>t;
while(t--){
cin>>n;
while(n--){
int so;
cin>>so;
if(so>0)
s.insert(so);
}
cout<<s.size()<<endl;
s.clear();
}
} int main() {
ios_base::sync_with_stdio(false);
#ifdef debug
freopen("in.txt", "r", stdin);
freopen("out.txt","w",stdout);
#endif
cin.tie(0);
cout.tie(0);
solve(); #ifdef debug
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return 0;
}
B. Vile Grasshoppers
给定一个[p,y]区间,找出其中最大的素数
#define debug
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#define pb push_back
using namespace std;
typedef long long ll;
pair<ll,ll>PLL;
pair<int,ll>Pil;
const ll INF = 0x3f3f3f3f;
const double inf=1e8+100;
const ll maxn =1e5+100;
const int N = 1e4+10;
const ll mod=1000007;
int p,y;
bool prime(int x) {
for(int i=2; i*i<=x&&i<=p; i++) {
if(x%i==0)
return 0;
}
return 1;
}
void solve() {
int i,j,t=1;
// cin>>t;
while(t--) {
cin >> p >> y;
for(i=y; i>p; i--) {
if(prime(i)) {
cout<<i<< endl;
return;
}
}
cout <<-1<< endl;
}
} int main() {
ios_base::sync_with_stdio(false);
#ifdef debug
freopen("in.txt", "r", stdin);
freopen("out.txt","w",stdout);
#endif
cin.tie(0);
cout.tie(0);
solve(); #ifdef debug
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return 0;
}
C. Save Energy!
一个炉子打开可以烧k时间,julia每d时间去厨房看一趟,一只鸡在炉子一直在烧的时候,烧熟需要t时间,否则需要2t
分析:实际上可以用时间来代表一只鸡烧熟需要的能量(2*t),所以炉子开着时产生的能量就为2*k,因此当
①k%d==0时,所花的时间就为t
②k%d!=0时,我们需要求一次循环的时间:d=(k/d+1)*d(包含k时间);循环的能量:circle=2*k+d-k;循环几次:ans=2*t/circle;剩余能量:t=2*t%circle。最后判断剩余的能量在哪一个位子:(I)t/2<=k,ans=ans*d+t/2 (II)t/2>k,ans=ans*d+k+t-2*k(设最后一段所需要的时间为tt,则t=tt-k+2*k即tt=t+k-2*k)
#define debug
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>PLL;
typedef pair<int,ll>Pil;
const ll INF = 0x3f3f3f3f;
const double inf=1e8+100;
const ll maxn =1e4+100;
const int N = 1e4+10;
const ll mod=1000007;
const int ml=1e6;
ll k,d,t,ans=0;
void solve() {
int i,j,tt=1;
// cin>>t;
while(tt--){
ll x;
cin>>k>>d>>t;
if(k%d==0){
cout<<t<<endl;
}
else{
d=(k/d+1)*d;
t*=2;
x=d+k;
ans=(t/x)*d;
t%=x;
if(t<=2*k){
cout<<fixed<<setprecision(2)<<(double)ans+t*0.5<<endl;
}
else{
t-=2*k;
ans+=k;
cout<<ans+t<<endl;
}
}
}
} int main() {
ios_base::sync_with_stdio(false);
#ifdef debug
freopen("in.txt", "r", stdin);
// freopen("out.txt","w",stdout);
#endif
cin.tie(0);
cout.tie(0);
solve();
#ifdef debug
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return 0;
}
codeforce round #467(div.2)的更多相关文章
- Codeforces Round #467 (div.2)
Codeforces Round #467 (div.2) 我才不会打这种比赛呢 (其实本来打算打的) 谁叫它推迟到了\(00:05\) 我爱睡觉 题解 A. Olympiad 翻译 给你若干人的成绩 ...
- Codeforces Round #467 (Div. 1) B. Sleepy Game
我一开始把题目看错了 我以为是博弈.. 这题就是一个简单的判环+dfs(不简单,挺烦的一题) #include <algorithm> #include <cstdio> #i ...
- Codeforces Round #467 (Div. 1). C - Lock Puzzle
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> ...
- codeforce round#466(div.2)C. Phone Numbers
C. Phone Numbers time limit per test2 seconds memory limit per test256 megabytes inputstandard input ...
- codeforce round#466(div.2) B. Our Tanya is Crying Out Loud
B. Our Tanya is Crying Out Loud time limit per test1 second memory limit per test256 megabytes input ...
- Codeforce Round #555 Div.3 D - N Problems During K Days
构造题 话说挺水的题..当时怎么就WA到自闭呢.. 先把每个位置按照最低要求填满,也就是相差1..然后从最后一位开始把剩下的数加上,直到不能加为止. #include <bits/stdc++. ...
- Codeforce Round #554 Div.2 C - Neko does Maths
数论 gcd 看到这个题其实知道应该是和(a+k)(b+k)/gcd(a+k,b+k)有关,但是之后推了半天,思路全无. 然而..有一个引理: gcd(a, b) = gcd(a, b - a) = ...
- Codeforces Round #467 Div. 1
B:显然即相当于能否找一条有长度为奇数的路径使得终点出度为0.如果没有环直接dp即可.有环的话可以考虑死了的spfa,由于每个点我们至多只需要让其入队两次,复杂度变成了优秀的O(kE).事实上就是拆点 ...
- Codeforces Round #467 (Div. 2) B. Vile Grasshoppers
2018-03-03 http://codeforces.com/problemset/problem/937/B B. Vile Grasshoppers time limit per test 1 ...
随机推荐
- Linux查看当前正在运行的进程
Linux查看当前正在运行的进程 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ps PID TTY TIME CMD 2576 pts/0 00:00:00 ...
- vue全局配置----小白基础篇
今天学习vue全局配置.希望帮助我们去了解vue的全局配置,快速开发. Vue.config是vue的全局配置对象.包含Vue的所有全局属性: silent:boolean(默认值:false)--- ...
- Java之CyclicBarrier使用,任务等待
1.类说明: 一个同步辅助类,它允许一组线程互相等待,直到到达某个公共屏障点 (common barrier point).在涉及一组固定大小的线程的程序中,这些线程必须不时地互相等待,此时 Cycl ...
- bzoj 4026 dC Loves Number Theory
把我写吐了 太弱了 首先按照欧拉函数性质 我只需要统计区间不同质数个数就好了 一眼主席树 其次我被卡了分解质因数这里 可以通过质数筛时就建边解决 不够灵性啊,不知道如何改 #include<bi ...
- [LNOI2014] LCA
题目描述: 网址:http://www.lydsy.com/JudgeOnline/problem.php?id=3626 大意: 给出一个n个节点的有根树(编号为0到n-1,根节点为0). 一个点的 ...
- [BZOJ4736]温暖会指引我们前行
BZOJ(BZOJ上的是什么鬼...) UOJ 任务描述 虽然小R住的宿舍楼早已来了暖气,但是由于某些原因,宿舍楼中的某些窗户仍然开着(例如厕所的窗户),这就使得宿舍楼中有一些路上的温度还是很低. 小 ...
- VMware下安装centos7及网络配置
之前遇到过用虚拟机安装上centos7上不了网,昨天解决了,但是手抽删错了,把centos7误删了,今天就一起安装下. 首先打开VMware,我这里用的版本是VMware12,然后我们新建虚拟机 下一 ...
- Storm 入门的Demo教程
Strom介绍 Storm是Twitter开源的分布式实时大数据处理框架,最早开源于github,从0.9.1版本之后,归于Apache社区,被业界称为实时版Hadoop.随着越来越多的场景对Hado ...
- python之hasattr()、 getattr() 、setattr() 函数
这三个方法可以实现反射和内省机制,在实际项目中很常用,功能也很强大. [转]http://www.cnblogs.com/cenyu/p/5713686.html hasattr(object, na ...
- MySQL多数据源笔记3-分库分表理论和各种中间件
一.使用中间件的好处 使用中间件对于主读写分离新增一个从数据库节点来说,可以不用修改代码,达到新增节点数据库而不影响到代码的修改.因为如果不用中间件,那么在代码中自己是先读写分离,如果新增节点, 你进 ...