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 ...
随机推荐
- Visual Studio2010重新安装后,冲突问题
http://www.docin.com/p-685665064.html VS2010重装后出错解决办法 一般在卸载VS2010之后,也重新安装了一遍,有的时候可能会出现如下问题: 1. 未能正确加 ...
- java查看程序执行时间
public static void main(String[] args) { long a= System.currentTimeMillis();//获取当前系统时间(毫秒) for (int ...
- CSS中的各种FC
什么是FC? Formatting Context,格式化上下文,指页面中一个渲染区域,拥有一套渲染规则,它决定了其子元素如何定位,以及与其他元素的相互关系和作用. BFC 什么是BFC Block ...
- SDP(12): MongoDB-Engine - Streaming
在akka-alpakka工具包里也提供了对MongoDB的stream-connector,能针对MongoDB数据库进行streaming操作.这个MongoDB-connector里包含了Mon ...
- leetcode【14题】Longest Common Prefix
题目:Longest Common Prefix 内容: Write a function to find the longest common prefix string amongst an ar ...
- 记录使用微信小程序的NFC和蓝牙功能读取15693芯片的开发历程
开发目标: (1) 对于Android手机,直接通过微信小程序调用手机的NFC功能,对15693协议的芯片进行读写操作: (2)对于苹果手机(及没有NFC模块的手机),通过微信小程序的蓝牙功能连接到蓝 ...
- ubuntu,kali linux和windows三系统流水账——写给自己
我先说一下ubuntu和windows双系统安装的几种方法,最后总结kali linux的安装,想起什么写什么,所以有点乱.然后记录一下自己的使用过程中遇见的问题和解决的方法,还有我的个人建议. 我个 ...
- object转字符串
1.obj.tostring() obj为空时,抛异常. 2.convert.tostring(obj) obj为空时,返回null: 3.(string)obj obj为空时,返回null:obj不 ...
- svn从Windows服务器上迁移到Linux上
svn从Windows服务器迁移到Linux服务器 author:headsen chen 2017-10-16 16:50:32 个人原创,转载请注明.否则依法追究法律责任 ...
- 初尝Eclipse
一.选择开发工具 1.Eclipse和JDK 我所选用的是Eclipse开发工具,此工具可以用来编译JAVA语言,但windows系统没有内置的JAVA运行环境,所以需要下载JDK,用来配置JAVA的 ...