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)的更多相关文章

  1. Codeforces Round #467 (div.2)

    Codeforces Round #467 (div.2) 我才不会打这种比赛呢 (其实本来打算打的) 谁叫它推迟到了\(00:05\) 我爱睡觉 题解 A. Olympiad 翻译 给你若干人的成绩 ...

  2. Codeforces Round #467 (Div. 1) B. Sleepy Game

    我一开始把题目看错了 我以为是博弈.. 这题就是一个简单的判环+dfs(不简单,挺烦的一题) #include <algorithm> #include <cstdio> #i ...

  3. Codeforces Round #467 (Div. 1). C - Lock Puzzle

    #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> ...

  4. codeforce round#466(div.2)C. Phone Numbers

    C. Phone Numbers time limit per test2 seconds memory limit per test256 megabytes inputstandard input ...

  5. 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 ...

  6. Codeforce Round #555 Div.3 D - N Problems During K Days

    构造题 话说挺水的题..当时怎么就WA到自闭呢.. 先把每个位置按照最低要求填满,也就是相差1..然后从最后一位开始把剩下的数加上,直到不能加为止. #include <bits/stdc++. ...

  7. 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) = ...

  8. Codeforces Round #467 Div. 1

    B:显然即相当于能否找一条有长度为奇数的路径使得终点出度为0.如果没有环直接dp即可.有环的话可以考虑死了的spfa,由于每个点我们至多只需要让其入队两次,复杂度变成了优秀的O(kE).事实上就是拆点 ...

  9. 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 ...

随机推荐

  1. PL/SQL 记录 Record 简介

    记录类型是表中当行数据结构的一个镜像.每个记录只存储一行数据,记录包含的是字段,而不是列. 1.用%rowtype属性隐式定义记录类型 declare individual individuals%r ...

  2. Caused by: org.xml.sax.SAXParseException; lineNumber: 28; columnNumber: 81;

    1.错误描述 严重: Exception sending context initialized event to listener instance of class org.springframe ...

  3. (二十九)java条件控制语句培训笔记

    java结构控制语句示例:if,if else,switch case 定义三个变量: :在这个例子中,if并列,则每一次都会进行判断,条件为true则输出里边的内容 ,因此,这里会输出one和fou ...

  4. CentOS持久化二进制日志(systemd日志)

    1.创建日志存储文件 /var/log/journal 2.改变存储文件属主属组 chown root:systemd-journal /var/log/journal/ 3.修改文件权限 chmod ...

  5. 异常-----freemarker.template.TemplateException: The only legal comparisons are between two numbers, two strings, or two dates

    1.错误描述 六月 26, 2014 10:44:49 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...

  6. 【BZOJ3944】Sum(杜教筛)

    [BZOJ3944]Sum(杜教筛) 题面 求\[\sum_{i=1}^n\mu(i)和\sum_{i=1}^n\phi(i)\] 范围:\(n<2^{31}\) 令\[S(n)=\sum_{i ...

  7. 【POJ3207】Ikki's Story IV - Panda's Trick

    POJ 3207 Ikki's Story IV - Panda's Trick liympanda, one of Ikki's friend, likes playing games with I ...

  8. 【BZOJ4538】【HNOI2016】网络(树链剖分,线段树,堆)

    题目链接,我是真的懒得调题目的格式... 题解 树链剖分搞一下LCA 把线段树弄出来 这只是形式上的线段树 本质上是维护一段区间的一个堆 每次把堆插入节点, 询问的时候查询线段树上的堆的最大值就行了 ...

  9. 关系型数据库工作原理-SQL重写(翻译自Coding-Geek文章)

    本文翻译自Coding-Geek文章:< How does a relational database work>.原文链接:http://coding-geek.com/how-data ...

  10. XAMPP搭建PHP

    在学习一些前后端交互时,经常会有跟PHP作为后端(服务器)的交互,不能将php文件放在本地进行请求,必须将PHP运行在Apache环境中.但是对一些新手来说,学习搭建一个Apache环境也并非易事,所 ...