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. ExtJS4.2学习(七)EditorGrid可编辑表格(转)

    鸣谢地址:http://www.shuyangyang.com.cn/jishuliangongfang/qianduanjishu/2013-11-14/176.html ------------- ...

  2. 通过PLSQL Developer导入SQL文件

    1.点击“工具” 2.选中其中的“导入表(L)”,在按下图所示操作: PLSQL Developer会自动运行相关命令,在Tables中刷新即可看到新导入的表.

  3. 如何循环遍历document.querySelectorAll()方法返回的结果

    使用JavaScript的forEach方法,我们可以轻松的循环一个数组,但如果你认为document.querySelectorAll()方法返回的应该是个数组,而使用forEach循环它: /* ...

  4. [转载]Dotfuscator Professional Edition 4.9.7500.9484 混淆工具破解版+使用教程

    如有转载,请注明出处: http://www.cnblogs.com/flydoos/archive/2012/01/26/2329536.html Dotfuscator Professional ...

  5. 学点PYTHON基础的东东--数据结构,算法,设计模式---访问者模式

    说实话,感觉不是特别多,可能没遇到过多场面, 所以对应用场景没感觉吧. 反正,各种模式就是把类的实例传来传去,久而久之,产生了一些规律...:) # 轮子,引擎, 车身这些定义好了都不需要变动 cla ...

  6. Java中获取完整的访问url

    Java中获得完整的URl字符串: HttpServletRequest httpRequest=(HttpServletRequest)request; String strBackUrl = &q ...

  7. ajax readyState的五种状态详解

    通过ajax的readyState的值,我们可以知道当前的这个http请求处于什么状态.对于web的调试是比较重要的. readyState 状态说明: (0)未初始化 此阶段确认XMLHttpReq ...

  8. RGB颜色查询对照表

    RGB颜色查询对照表     RGB颜色对照表   #FFFFFF2015-02-05   #FFFFF0   #FFFFE0   #FFFF00   #FFFAFA   #FFFAF0   #FFF ...

  9. bash把所有屏幕输出重定向到文件并保持屏幕输出的方法

    输出到文件log中,并在屏幕上显示:#ls >&1 | tee log 追加输出到文件log中,并在屏幕上显示:#ls >&1 | tee -a log

  10. html5自带表单验证-美化改造

    神奇的代码 暂且叫做html5.css /* === HTML5 validation styles === */ .myform select:required, .myform input:req ...