The 2019 University of Jordan Collegiate Programming Contest
链接:https://codeforc.es/gym/102267
A. Picky Eater
直接比较
int main(){
int x ,y;
scanf("%d %d" ,&x ,&y);
if(x>=y){
return printf(""),;
}
else return printf(""),;
return ;
}
B. Primes
素数筛,log判断
int prime[maxn],num_prime = ;
int vis[maxn];
void is_prime(int N){
for(int i=;i<=N;i++){
if(!vis[i]){
prime[num_prime++] = i;
vis[i] = i;
}
for(int j=;j<num_prime&&i*prime[j]<=N;j++){
vis[i*prime[j]] = prime[j];
if(!(i%prime[j])){
break;
}
}
}
return;
}
int n;
int main(){
scanf("%d", &n);
is_prime(n);
for(int i = ; i < num_prime; i++){
int j = prime[i];
int p = lower_bound(prime,prime+num_prime,n-j)-prime;
if(prime[p]==n-j){
return printf("%d %d",j,n-j),;
} }
printf("-1");
return ;
}
C. Matryoshka Dolls
一个循环
int x,y;
int main(){
scanf("%d %d", &x, &y);
int ans = ;
while(x){
ans++;
x/=y;
}printf("%d",ans);
return ;
}
D. Robots Easy
12*12,直接rand乱跑
#include<iostream>
#include<cstdio>
#include<algorithm>
//#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1 using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = ;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
//const db pi = acos(-1.0); int x,y;
int a[][];
vector<char>ans;
int dx,dy;
inline int Rand(){
static int seed = ;
return seed = (int)((((seed ^ ) + 19260817ll) * 19890604ll) % );
}
int main(){
int t;
scanf("%d", &t);
a[][]=a[][]=a[][]=a[][]=;
a[][]=a[][]=a[][]=;
a[][]=a[][]=a[][]=;
a[][]=a[][]=a[][]=a[][]=;
while(t--){
ans.clear();
scanf("%d %d" ,&x ,&y);
while(a[x][y]!=){
//printf("%d %d\n",x,y);
int op;
while(op=rand()%){
dx=dy=;
char ch;
if(op==){dx=-;ch='U';}
if(op==){dx=;ch='D';}
if(op==){dy=-;ch='L';}
if(op==){dy=;ch='R';}
if(op==)continue;
//printf(" %d\n",op);
if(x+dx>=&&x+dx<=&&y+dy>=&&y+dy<=){
if(a[x+dx][y+dy]==)continue;
x+=dx;y+=dy;
ans.pb(ch);
break;
}
else continue;
}
}
printf("%d\n",ans.size());
for(int i = ; i < (int)ans.size(); i++){
printf("%c",ans[i]);
}printf("\n"); }
return ;
}
H. Circle of Polygon
一个公式
double v,s;
int main(){
scanf("%lf %lf", &v, &s);
printf("%.9lf",1.0/2.0*pi*s*s/(1.0-cos(*pi/v))); return ;
}
I. Ultimate Army
左括号之后一定跟一个数,遇到左括号,下一个数的sup就是栈顶,遇到数字入栈,遇到右括号出栈
int n;
char a[maxn];
stack<int>s;
vector<int>v;
int ans[maxn];
int main(){
scanf("%d", &n);
scanf("%s",a+);
int len = strlen(a+);
int tmp = ;
int gao = ;
for(int i = ; i <= len; i++){
if(a[i]>=''&&a[i]<=''){
tmp*=;
tmp+=a[i]-'';
}
else{
if(tmp!=)v.pb(tmp);
tmp=;
}
if(a[i]=='(')v.pb(-);
else if(a[i]==')')v.pb(-);
}
for(int i = ; i < (int)v.size(); i++){
if(v[i]>){
if(gao)ans[v[i]]=s.top();
s.push(v[i]);
gao=;
}
else if(v[i]==-){
gao=;
}
else if(v[i]==-){
s.pop();
}
}
for(int i = ; i <= n; i++){
printf("%d ",ans[i]);
}
return ;
}
K. Birthday Puzzle
2^20暴力dfs维护答案即可
ll ans;
int n;
int a[maxn];
void dfs(int x, int now){
if(x==n+){
ans+=now;
return;
}
dfs(x+,now|a[x]);
dfs(x+,now);
}
int main(){
scanf("%d", &n);
for(int i = ; i <= n; i++){
scanf("%d", &a[i]);
}
dfs(,);
printf("%lld",ans);
return ;
}
The 2019 University of Jordan Collegiate Programming Contest的更多相关文章
- ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syria, Lattakia, Tishreen University, April, 30, 2018
ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syr ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)
Floor Function Time Limit: 10 Seconds Memory Limit: 65536 KB a, b, c and d are all positive int ...
- 模拟赛小结:2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017)
比赛链接:传送门 本场我们队过的题感觉算法都挺简单的,不知道为啥做的时候感觉没有很顺利. 封榜后7题,罚时1015.第一次模拟赛金,虽然是北欧的区域赛,但还是有点开心的. Problem B Best ...
- The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540
Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Othe ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...
随机推荐
- 你不得不了解Helm 3中的5个关键新特性
Helm是Kubernetes的一个软件包管理器.两个月前,它发布了第三个主要版本,Helm 3.在这一新版本中,有许多重大变化.本文将介绍我认为最关键的5个方面. 1. 移除了Tiller Helm ...
- how to render html tag
使用autoescaping If autoescaping is turned on in the environment, all output will automatically be esc ...
- JSP九大内置对象之session以及eclispe如何关联源码
一.session的特点及其实例 session:同一次会话共享 a.浏览网站:开始->关闭 b.购物:浏览.付款.退出 c.电子邮件:浏览.写邮件.退出 从一次开始到一次结束,是一次会话. ...
- python中类的输出或类的实例输出为何是<__main__类名 object at xxxx>这种形式?
原因: __str__()这个特殊方法将对象转换为字符串的结果 效果图: 代码: # 定义一个Person类 class Person(object): """人类&qu ...
- Appium自动化测试框架研究(2)——搭建IOS环境
今天的文章讲iOS的Appium环境搭建. 对于iOS而言,只能在Mac笔记本上安装Appium,以及所需要的各种组件. 也许有人会问,能否在Windows系统上使用Appium测试iOS手机,这不就 ...
- Scrum.自用SCRUM项目开发流程
目前团队所使用的开发模式流程,请大家指正优化. 1.PM需求整理:在禅道整理出需求清单和原型图(标注清楚):需求评审.往复,直到需求定稿. 2.SprintMaster根据需求清单进行技术任务拆解,包 ...
- python 自定义expection
class PricePolicyInvalid(Exception): def __init__(self, msg): self.msg = msg
- mysql 执行计划和慢日志记录
一.执行计划 1.作用预估sql语句执行的时间,一般准确2.格式: explain sql语句3.type类型的快慢(all最慢,const最快)all < index < range & ...
- 初探ASP.NET Core 3.x (4) - 项目的重要组成
目录 O 前请提要 I 启动部分 I.1 Program类 I.2 Startup类 I.2.1 这个类干什么呢?? I.2.2 特征?? I.3 appsettings.json I.4 launc ...
- MyBatis3——输出参数ResultType、动语态sql
输出参数ResultType 1.输出参数为简单类型(8个基本+String) 2.输出参数为对象类型 3.输出参数为实体对象类型的集合:虽然输出类型为集合,但是resultType依然写集合的元素类 ...