链接: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的更多相关文章

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

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

  3. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

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

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

  7. 模拟赛小结:2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017)

    比赛链接:传送门 本场我们队过的题感觉算法都挺简单的,不知道为啥做的时候感觉没有很顺利. 封榜后7题,罚时1015.第一次模拟赛金,虽然是北欧的区域赛,但还是有点开心的. Problem B Best ...

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

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

随机推荐

  1. Nginx 核心配置详解

    目录 Nginx 核心配置详解 Nginx 四层访问控制: Nginx账户认证功能: 自定义错误页面: 自定义访问日志: 检测文件是否存在: 长连接配置: 作为下载服务器配置: 作为上传服务器: 其他 ...

  2. 彻底掌握CORS跨源资源共享

    本文来自于公众号链接: 彻底掌握CORS跨源资源共享 ) 本文接上篇公众号文章:彻底理解浏览器同源策略SOP 一.概述 在云时代,各种SAAS应用层出不穷,各种互联网API接口越来越丰富,H5技术在微 ...

  3. echart两组柱状图对比时,不同类型根据各类型的最大值为基准进行展示

    项目中遇到的问题:因为数据太小,箭头的地方展示不出来,这时的两组对比数据是根据一个最大值为基准进行渲染的.但我们想实现不同类型的对比根据不同的基准值渲染. 理想效果如下图: 实现代码: option ...

  4. 竹马竹马chikuma

    [问题描述] 众所周知,zzh 和 heyi 是一对竹马竹马,他们从小一起学 C++,最后都成了著名的神犇.而时间回溯到他们童年,这天 zzh 邀请 heyi 来参加 zzh 举行的男性家庭聚会. 而 ...

  5. 谈谈Java的Collection接口

    目录 谈谈Collection 前言 Collection 方法 1.boolean add(E) 2.void clear() 3.boolean contains(Object o) 4.bool ...

  6. 你还不会Git?那就不要写代码了(二)

    Git 命令练习 git的删除,添加,修改与日志 which vi 查看命令的目录 ⌃ a 光标去开头 ⌃ E 光标去结尾 ehco 'hellow world asd' > test.txt ...

  7. wannafly 27 D 巧妙求取约数

    链接:https://www.nowcoder.com/acm/contest/215/D来源:牛客网 题目描述 “我不知道你在说什么,因为我只是个pupil.”--绿魔法师 一个空的可重集合S. n ...

  8. Windows10内嵌Ubuntu子系统初始化设置

    第一次启动 重启ubuntu Since Windows 10 version 1803, closing all WSL terminal windows won't kill background ...

  9. 12.instanceof和类型转换

    Instanceof: 判断一个对象是什么类型的~,可以判断两个类之间是否存在父子关系 package com.oop.demo07; public class Person { public voi ...

  10. windows下远程访问Linux系统中mysql

    1,查询MySQL数据库是否允许远程ip访问,命令如下: sql语句: use mysql; select host, user from user; 查询结果为127.0.0.1或者localhos ...