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. 基于局部敏感哈希的协同过滤算法之simHash算法

    搜集了快一个月的资料,虽然不完全懂,但还是先慢慢写着吧,说不定就有思路了呢. 开源的最大好处是会让作者对脏乱臭的代码有羞耻感. 当一个做推荐系统的部门开始重视[数据清理,数据标柱,效果评测,数据统计, ...

  2. spoj 364

    动规  f[i][j]表示第i到第j个数能取到的最大值 e[i][j]表示最小值 ....... #include <cstdio> #include <cstring> us ...

  3. Python 开源异步并发框架的未来

    http://segmentfault.com/a/1190000000471602 开源 Python 是开源的,介绍的这几个框架 Twisted.Tornado.Gevent 和 tulip 也都 ...

  4. Making your local server accessible from anywhere

    In reality you probably don’t want to host you websites on your local computer unless you have a ver ...

  5. ***用php的strpos() 函数判断字符串中是否包含某字符串的方法

    判断某字符串中是否包含某字符串的方法 if(strpos('www.idc-gz.com','idc-gz') !== false){ echo '包含'; }else{ echo '不包含'; } ...

  6. 学点PYTHON基础的东东--数据结构,算法,设计模式---单向链表

    看来看来,还是以下这个实现最优雅.. 其它的,要么NODE冗余,要么初始化丑陋... #!/usr/bin/env python # -*- coding: utf-8 -*- class Node: ...

  7. UR #13 Ernd

    考试的时候没有注意到可以将(a,b)放在二维平面上之后旋转坐标系,使得转移变成树状数组二维偏序 这样就算我想出来了第二个转移的斜率优化也没有什么卵用啊(摔西瓜 设g(i)表示当前站在第i个水果下面且第 ...

  8. JavaBean 内省API BeanUtils工具 泛型 xml xml约束

    1 什么是JavaBean?有何特征? 1)符合特定规则的类    2)JavaBean分二类:     a)侠义的JavaBean         .私有的字段(Field)         .对私 ...

  9. javascript 小日历

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx. ...

  10. C#中的多文档的使用

    1.首先,新建一个窗体,设置窗体的IsMdiContainer = true; 窗体的大小为700*600  长700  高600 2.在窗体的Load事件中添加如下代码 private void F ...