https://icpc.baylor.edu/regionals/finder/north-america-qualifier-2015

一个人打。。。。

B

概率问题公式见代码

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre() {
freopen("in.txt","r",stdin);
} inline int r(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} int countt;
int comb1(int m,int k)
{
int i;
for (i=m;i>=k;i--)
{
if (k>)
{
comb1(i-,k-);
}
else
{
countt++;
}
}
return countt;
} int main(){
// fre();
int T;
int R,s,x,y,w;
T=r();
while(T--){
double p1=0.0;
int num;
cin>>R>>s>>x>>y>>w;
double p=(s-R+)*1.0/s;
double ans=0.0;
for(int i=x;i<=y;i++){
int c=y-i;
p1=1.0;
double p2=1.0-p;
while(c--){
p1*=p2;
}
int cc=i;
double P=1.0;
for(int j=;j<=i;j++){
P*=p;
}
// cout<<i<<" "<<P<<endl;
countt=;
num=comb1(y,i);
// cout<<P<<" "<<p1<<" "<<num<<endl;
ans+=P*p1*num;
}
// cout<<ans<<endl;
if(ans*w>)
printf("yes\n");
else
printf("no\n");
}
return ;
}

F

水题

输出字符串中缺少的字母

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre(){freopen("in.txt","r",stdin); }
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// }
int a[];
char ans[];
int main()
{ int T;
scanf("%d",&T);
getchar();
while(T--)
{
clc(a,);
clc(ans,);
string s;
getline(cin,s);
for(int i = ; i < s.length(); i ++){
if(s[i] >= 'a' && s[i] <= 'z')
a[s[i] - 'a'] ++;
if(s[i] >= 'A' && s[i] <= 'Z')
a[s[i] - 'A'] ++;
}
int k = ;
for(int i = ; i < ; i ++){
if(!a[i]){
ans[k++] = i + 'a';
}
}
if(k ==) {
printf("pangram\n");
}
else{
printf("missing ");
for(int i = ; i< k; i ++){
printf("%c",ans[i]);
}
printf("\n");
}
}
return ;
}

G

过河的经典问题

多个人过河每次船上必须有一人问最短时间

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre() {
freopen("in.txt","r",stdin);
} inline int r(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} int TravelBridge(std::vector<int> times)
{
size_t length = times.size();
if(length <= )
return times[length-];
else if(length == )
{
return times[] + times[] + times[];
}
else
{
int totaltime = ;
int a = times[];
int b = times[];
int z = times[length-];
int y = times[length-];
if(b* < a + y)
{
times.erase(times.end()-);
times.erase(times.end()-);
totaltime += b + a + z + b + TravelBridge(times);
}
else
{
times.erase(times.end()-);
totaltime += z + a + TravelBridge(times);
}
return totaltime;
}
} int main(){
int n;
n=r();
vector<int> v;
for(int i=;i<n;i++){
int x;
x=r();
v.push_back(x);
}
sort(v.begin(),v.end());
int ans=TravelBridge(v);
printf("%d\n",ans);
return ;
}

H

水题

旋转矩阵再输出

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre() {
freopen("in.txt","r",stdin);
} inline int r(){
int x=,f=;char ch=getchar();
while(ch>''||ch<''){if(ch=='-') f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} char s[];
char a[][];
int main() {
// fre();
int T;
T=r();
// getchar();
while(T--) {
scanf("%s",s);
int len = strlen(s);
int q = ;
for(; ; q ++) {
if(q * q >= len) {
break;
}
}
// cout<<s[0]<<endl;
int pos;
for(int i = ; i < q; i ++) {
for(int j = ; j < q ; j ++) {
pos = i * q + j;
if(pos >= len) {
a[i][j] = '*';
} else {
a[i][j] = s[pos];
}
}
}
// printf("%c\n",a[0][0]);
// for(int i=0;i<q;i++){
// for(int j=0;j<q;j++){
// printf("%c ",a[i][j]);
// }
// printf("\n");
// }
for(int j = ; j < q ; j ++) {
for(int i = q - ; i >= ; i --) {
if(a[i][j] != '*')
printf("%c",a[i][j]);
}
}
printf("\n");
}
return ;
}

J

把单词映射成数字

从起点到终点搜索

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <list>
#include <map>
#include <stack>
#include <vector>
#include <cstring>
#include <sstream>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
const int MOD = 1e9+;
#define LL long long
void fre() {
freopen("in.txt","r",stdin);
}
inline int r() {
int x=,f=;
char ch=getchar();
while(ch>''||ch<'') {
if(ch=='-') f=-;
ch=getchar();
}
while(ch>=''&&ch<='') {
x=x*+ch-'';
ch=getchar();
}
return x*f;
} int a[][] = {};
int p[];
string s[];
int n;
int ans[];
bool idx[] = {false};
int num = ;
map<string,int> mapp; void dfs(int u,int v) {
if(u == v)
return;
idx[u] = true;
for(int i = ; i <= num; i ++) {
if(a[u][i] == && idx[i] == false) {
p[i] =u;
dfs(i,v);
}
}
idx[u] = false;
} int main() {
clc(a,);
mapp.clear();
n=r();
// getchar();
string line,x;
string s1,s2;
int k = ;
int t;
bool flag = false;
int u,v;
for(int i =; i < n; i ++) {
getline(cin,line);
stringstream ss(line);
ss>>x;
if(mapp[x] == ) {
mapp[x] = num;
s[num] = x;
num ++;
}
u = mapp[x];
while(ss >> x) {
if(mapp[x] == ) {
mapp[x] = num;
s[num] = x;
num ++;
}
v = mapp[x];
a[u][v] = ;
a[v][u] = ;
}
}
cin>>s1>>s2;
if(mapp[s1] == ) {
mapp[s1] = num;
num ++;
}
u= mapp[s1];
if(mapp[s2] == ) {
mapp[s2] = num;
num ++;
}
v = mapp[s2];
dfs(u,v);
p[u] = -;
t = v;
while(t != -) {
ans[k ++] = t;
if(t == ) {
flag = true;
break;
}
t = p[t];
}
if(flag == true) {
printf("no route found\n");
return ;
}
for(int i = k - ; i >= ; i --) {
cout<<s[ans[i]]<<" ";
}
cout<<s[v]<<endl; }

一个人打也挺好玩的

North America Qualifier (2015)的更多相关文章

  1. East Central North America Region 2015

    E 每过一秒,当前点会把它的值传递给所有相邻点,问t时刻该图的值 #include <iostream> #include <cstdio> #include <algo ...

  2. 2019 ACM/ICPC North America Qualifier G.Research Productivity Index(概率期望dp)

    https://open.kattis.com/problems/researchproductivityindex 这道题是考场上没写出来的一道题,今年看看感觉简单到不像话,当时自己对于dp没有什么 ...

  3. 2015 UESTC Winter Training #6【Regionals 2010 >> North America - Rocky Mountain】

    2015 UESTC Winter Training #6 Regionals 2010 >> North America - Rocky Mountain A - Parenthesis ...

  4. Regionals 2013 :: North America - Southeast USA

    Regionals 2013 :: North America - Southeast USA It Takes a Village As a Sociologist, you are studyin ...

  5. MPI Maelstrom(East Central North America 1996)(poj1502)

    MPI Maelstrom 总时间限制:  1000ms 内存限制:  65536kB 描述 BIT has recently taken delivery of their new supercom ...

  6. poj 2732 Countdown(East Central North America 2005)

    题意:建一个家庭树,找出有第d代子孙的名字,按照要求的第d代子孙的数从大到小输出三个人名,如果有一样大小子孙数的,就按字母序从小到大将同等大小的都输出,如果小于三个人的就全输出. 题目链接:http: ...

  7. [New Portal]Windows Azure Cloud Service (34) TechEd 2013 North America关于Azure的最新消息

    <Windows Azure Platform 系列文章目录> 话说TechEd 2013 US上个月3-6日在美国举办了,笔者的文章又有点姗姗来迟了. 需要了解相关视频的网友,请浏览ht ...

  8. 组队练习赛(Regionals 2012, North America - East Central NA)

    A.Babs' Box Boutique 给定n个盒子,每个盒子都有长宽高(任意两个盒子长宽高不完全相同),现在选盒子的任意两面,要求x1 <= x2 && y1 <= y ...

  9. Regionals 2012, North America - Greater NY 解题报告

    这套题..除了几何的都出了 完全没时间学几何.杯具 A,B,J 水题不解释 C.Pen Counts 这题的话 写几个不等式限制边得范围就行了 然后枚举最小边 D.Maximum Random Wal ...

随机推荐

  1. HTTP协议的几个重要概念

    转自:http://ice-cream.iteye.com/blog/77549 1.连接(Connection):一个传输层的实际环流,它是建立在两个相互通讯的应用程序之间. 2.消息(Messag ...

  2. [转]LINQ操作数据库

    查询表达式(LINQ)简介 C#3.0新语特性和改进,这些新特性在我们编写程序时为我们提供了非常大的帮助.从这篇开始,我们开始一起来探讨LINQ. LINQ是Language Integrated Q ...

  3. Samza文档翻译 : Concepts

    此页介绍啊Samza的一些高层级概念. Streams Samza处理Streams(流).流由同一类型的不可变的消息组成.例如,一个流可以是对一个网站的所有点击,或者对一个数据库表的所有更新,或者一 ...

  4. DIY Ruby CPU 分析 Part II

    [编者按]作者 Emil Soman,Rubyist,除此之外竟然同时也是艺术家,吉他手,Garden City RubyConf 组织者.本文是 DIY Ruby CPU Profiling 的第二 ...

  5. 用printf做彩色日志记录

    写了一个简单的程序,但是考虑到有一些信息是需要打印在控制台上的,就像在windows上启动apache tomcat时控制台显示的信息一样.琢磨一会儿之后,对printf进行了封装,支持控制台打印日志 ...

  6. 提供几个可注册的edu邮箱链接

    旧版的邮箱大全有edu邮箱的专题页面,放出来2个国内edu.cn邮箱的注册地址:@live.shop.edu.cn和@abc.shop.edu.cn,现在已经停止开放注册了. 其实旧版中还做了个隐藏的 ...

  7. 利用CCProxy管理小型企业的上网行为

    本实验以实例方式,从操作条件.背景.需求.以及具体要求的几个部分进行说明. 1. 操作条件: 装有Windows Server 2003系统,安装了代理服务程序的虚拟机一台 2. 背景: 为了提高员工 ...

  8. 安装Hadoop系列 — 安装Hadoop

    安装步骤如下: 1)下载hadoop:hadoop-1.0.3     http://archive.apache.org/dist/hadoop/core/hadoop-1.0.3/   2)解压文 ...

  9. 泛型编程、STL的概念、STL模板思想及其六大组件的关系,以及泛型编程(GP)、STL、面向对象编程(OOP)、C++之间的关系

    2013-08-11 10:46:39 介绍STL模板的书,有两本比较经典: 一本是<Generic Programming and the STL>,中文翻译为<泛型编程与STL& ...

  10. Invoke BeginInvoke

    http://www.codeproject.com/Articles/10311/What-s-up-with-BeginInvoke http://www.codeproject.com/Arti ...