codeforce round #467(div.2)
2024-08-20 17:37:04
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;
}
最新文章
- JSP 简介
- PAT (Advanced Level) Practise:1001. A+B Format
- ios开发分类--NSDate+Helpers
- Varnish缓存服务器的搭建配置手册
- 六种排序的C++实现
- spice-vdagent
- [图形学] Chp14 GLU曲面裁剪函数程序示例及样条表示遗留问题
- iot前台开发环境:前后台访问映射
- 程序员如何巧用Excel提高工作效率 第二篇
- vue+weui+FormData+XMLHttpRequest 实现图片上传功能
- redisson整合spring
- Runtime个别API的使用
- [leetcode]66. Plus One加一
- MySQL去除查询结果重复
- PHP中stdClass的意义
- Django时区的解释
- python之语音识别(speech模块)
- Ubuntu 上 执行命令 java -version 显示 没有那个文件或目录
- Android 使用GPS获取到经纬度后 无法在Android8.0上使用Geocoder类获取位置信息
- 如何查看页面是否开启了gzip压缩
热门文章
- 把连续动态bmp转换为avi
- 查找IFileSourceFilter上的Pin
- Java高并发之从零到放弃
- 【SPOJ】Longest Common Substring II (后缀自动机)
- 【SPOJ】Distinct Substrings(后缀自动机)
- Spring【AOP模块】就是这么简单
- Windows Developer Day - MSIX and Advanced Installer
- Windows下GO的开发环境配置
- react-native导航器 react navigation 介绍
- QBlog V2.5 源码开放下载(ASP.NET 番外系列之开端)