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; }

一个人打也挺好玩的

最新文章

  1. Mac入门(三)使用brew安装软件
  2. Quartz.net 开源job调度框架(一)
  3. junit4 assert类中的assert方法总结
  4. code first 创建和初始化数据库
  5. generated clock
  6. Mybatis对MySQL中BLOB字段的读取
  7. Cocos2d-x网络通信
  8. Excel两行交换及两列交换,快速互换相邻表格数据的方法
  9. dispatch队列
  10. 130825组队赛-Regionals 2012, North America - East Central NA
  11. 【Python】协程实现生产者消费者模型
  12. 浏览器加载和渲染html的顺序(html/css/js)
  13. 通过模拟JDK中的动态代理,由浅入深讲解动态代理思想.
  14. js复制粘贴模板
  15. Python turtle学习笔记
  16. Spring 静态代理+JDK动态代理和CGLIB动态代理
  17. LeetCode--434--字符串中的单词数
  18. .NET MVC5+ Dapper+扩展+AutoFac自动注入实现
  19. Push rejected: Push master to origin/master was rejected /failed to push some refs to /git did not exit cleanly
  20. centos7 磁盘管理—— lvm的使用

热门文章

  1. ExtJS4.2学习(九)属性表格控件PropertyGrid(转)
  2. XSS 攻击在它的面前都弱爆了!
  3. PHP 7 值得期待的新特性(上)
  4. android 使用Activity做窗口弹出(模拟Dialog)
  5. 我见过的 Objective-C, 讲的最通俗易懂的入门教程....
  6. google maps v3 添加自定义图标(marker,overlay)
  7. [itint5]单词变换
  8. kali2.0 系统自带截图功能
  9. 完全掌握Android Data Binding
  10. Android安全问题 抢先接收广播 - 内因篇之广播发送流程