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;
}

  

最新文章

  1. JSP 简介
  2. PAT (Advanced Level) Practise:1001. A+B Format
  3. ios开发分类--NSDate+Helpers
  4. Varnish缓存服务器的搭建配置手册
  5. 六种排序的C++实现
  6. spice-vdagent
  7. [图形学] Chp14 GLU曲面裁剪函数程序示例及样条表示遗留问题
  8. iot前台开发环境:前后台访问映射
  9. 程序员如何巧用Excel提高工作效率 第二篇
  10. vue+weui+FormData+XMLHttpRequest 实现图片上传功能
  11. redisson整合spring
  12. Runtime个别API的使用
  13. [leetcode]66. Plus One加一
  14. MySQL去除查询结果重复
  15. PHP中stdClass的意义
  16. Django时区的解释
  17. python之语音识别(speech模块)
  18. Ubuntu 上 执行命令 java -version 显示 没有那个文件或目录
  19. Android 使用GPS获取到经纬度后 无法在Android8.0上使用Geocoder类获取位置信息
  20. 如何查看页面是否开启了gzip压缩

热门文章

  1. 把连续动态bmp转换为avi
  2. 查找IFileSourceFilter上的Pin
  3. Java高并发之从零到放弃
  4. 【SPOJ】Longest Common Substring II (后缀自动机)
  5. 【SPOJ】Distinct Substrings(后缀自动机)
  6. Spring【AOP模块】就是这么简单
  7. Windows Developer Day - MSIX and Advanced Installer
  8. Windows下GO的开发环境配置
  9. react-native导航器 react navigation 介绍
  10. QBlog V2.5 源码开放下载(ASP.NET 番外系列之开端)