woj1002-Genesis woj1003-birthofnoah woj1004-noah's ark
title: woj1002-Genesis
date: 2020-03-05
categories: acm
tags: [acm,woj]
输入输出考虑一下。easy
#include <iostream>
#include <string>
#include<cctype>
using namespace std;
// 考虑换行.最后 .和字母在一起不考虑。cin空格截断,刚好
int main (){
int first=1,cnt=0;
string s;
while(cin>>s){ //EOF 考虑换行,换行后输出上一组的cnt.first=1表示第一行
if(isdigit(s[0])){
if (first)
{ cout<<s<<" "; first=0;}
else{
cout<<cnt<<endl; cnt=0;cout<<s<<" "; }
}
else if(isalpha(s[0])) cnt++; //s[0] >= 'a' && s[0] <= 'z') || (s[0] >= 'A' && s[0] <= 'Z')
}
cout<<cnt<<endl; //EOF
return 0;
}
title: woj1003-birthofnoah
date: 2020-03-04
categories: acm
tags: [acm,woj,数据结构]
简单题。用到map,pair,typedef,iterater。
好久没做,生疏了好多。
description:略
#include<map>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef pair<int,int> info; //ancestor,age
map<string,info> family = {{"Adam",make_pair(1,930)},{"Seth",make_pair(2,912)},
{"Enosh",make_pair(3,905)},{"Kenan",make_pair(4,910)},
{"Mahalalel",make_pair(5,895)},{"Jared",make_pair(6,962)},{"Enoch",make_pair(7,365)},{"Methuselah",make_pair(8,969)},
{"Lamech",make_pair(9,777)},{"Noah",make_pair(10,-1)},{"Shem",make_pair(11,-1)},{"Ham",make_pair(11,-1)},{"Japheth",make_pair(11,-1)}};
/*好像struct更简单。但是查起来麻烦
struct people {
string name[20];
int ancestor;
int old;
}
*/
void initial(){
//复习一下
//info p;
//map<string,info> person;
//p=make_pair(1,930); //p.first,p.second
//person.insert(make_pair("Adam",p));
return;
}
int main(){
/*
string line;
while(getline(cin,line,'#'))
{cout <<line;
fflush(stdin);
}
*/
//initial();
//char name1[15],name2[15];
string name1,name2;
map<string,info>::iterator iter1,iter2;
while(cin>>name1>>name2) //cin空格截断.getline可以一行
{
// if(family.count(name1)>0) 必定存在,不判断
iter1=family.find(name1);
iter2=family.find(name2);
if(iter1->second.first==-1||iter2->second.first==-1) //注意map用-> pair用.
cout<<"No enough information"<<endl;
else if(iter1->second.first<iter2->second.first)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
if(iter1->second.second==-1||iter2->second.second==-1)
printf("No enough information\n");
else if(iter1->second.second>iter2->second.second)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
title: woj1004-noah's ark
date: 2020-03-05
categories: acm
tags: [acm,woj]
简单题。
注意浮点数的处理,用eps 1e-9.注意除法变乘法 a/b=6__a=6*b
description:略
// meters =100 cm 1 inch= 2.54cm feet=0.3048 m cubits 45.72cm
// meters/centimeters/inches/cubits/feet
#include<iostream>
#include <cmath>
const double eps=1e-9;
using namespace std;
//l==w 则spin。否则, Its length to width ratio of exactly six to one provided excellent stability on the high seas.
// fbs abs 求绝对值 cmath
double trans(double l,string unit){
if (unit[2]=='t')
l*=100;
else if(unit[2]=='c')
l*=2.54;
else if(unit[2]=='b')
l*=45.72;
else if(unit[2]=='e')
l*=30.48;
return l;
}
int main(){
string l,w,h;
int flag=0;
double ll,ww,hh;
while(cin>>ll){
cin>>l>>ww>>w>>hh>>h;
/*
if(!flag)
flag=1;
else
cout<<endl;
*/
ll=trans(ll,l);
ww=trans(ww,w);
if(fabs(ll-ww)<eps)
cout<<"Spin"<<endl;
else if(fabs(ll-6.0*ww)<eps) // 考虑 /0。之前先判断==0,没考虑全。
cout<<"Excellent"<<endl;
else
cout<<"Neither"<<endl;
cout<<endl;
}
return 0;
}
woj1002-Genesis woj1003-birthofnoah woj1004-noah's ark的更多相关文章
- 【机器学习Machine Learning】资料大全
昨天总结了深度学习的资料,今天把机器学习的资料也总结一下(友情提示:有些网站需要"科学上网"^_^) 推荐几本好书: 1.Pattern Recognition and Machi ...
- HDU-4057 Rescue the Rabbit(AC自动机+DP)
Rescue the Rabbit Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- ZOJ 3545 Rescue the Rabbit(AC自动机+状压DP)(The 2011 ACM-ICPC Asia Dalian Regional Contest)
Dr. X is a biologist, who likes rabbits very much and can do everything for them. 2012 is coming, an ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料【转】
转自:机器学习(Machine Learning)&深度学习(Deep Learning)资料 <Brief History of Machine Learning> 介绍:这是一 ...
- hdu 4057 AC自己主动机+状态压缩dp
http://acm.hdu.edu.cn/showproblem.php?pid=4057 Problem Description Dr. X is a biologist, who likes r ...
- hdu 4057--Rescue the Rabbit(AC自动机+状压DP)
题目链接 Problem Description Dr. X is a biologist, who likes rabbits very much and can do everything for ...
- CS100.1x-lab3_text_analysis_and_entity_resolution_student
这次作业叫Text Analysis and Entity Resolution,比前几次作业难度要大很多.相关ipynb文件见我github. 实体解析在数据清洗和数据整合中是一个很重要,且有难度的 ...
- NCE3
Lesson1 A puma at large Pumas are large, cat-like animals which are found in America. When reports ...
- hdu4057 Rescue the Rabbit
地址:http://acm.hdu.edu.cn/showproblem.php?pid=4057 题目: Rescue the Rabbit Time Limit: 20000/10000 MS ( ...
- 国内知名的自然语言处理(NLP)团队
工业界 腾讯人工智能实验室(Tencent AI Lab) 百度自然语言处理(Baidu NLP):对外提供了百度AI开放平台,王海峰(现任百度副总裁,AI技术平台体系AIG总负责人) 微软亚洲研究院 ...
随机推荐
- 03--Docker 容器和镜像常用命令
一.帮助命令 docker version docker info docker --help =====================镜像命令=========================== ...
- [Usaco2005 Dec]Scales 天平
题目描述 约翰有一架用来称牛的体重的天平.与之配套的是N(1≤N≤1000)个已知质量的砝码(所有砝码质量的数值都在31位二进制内).每次称牛时,他都把某头奶牛安置在天平的某一边,然后往天平另一边加砝 ...
- ElasticSearch7.2简单命令实操(postman版)
使用postman访问操作ElasticSearch数据库,数据格式均为json 目录 使用postman访问操作ElasticSearch数据库,数据格式均为json 一.集群设置 1.查看集群设置 ...
- Devexpress DockManager多页面浮动窗口会关闭所有页面的问题
注册 DockManager 的 ClosingPanel 事件 private void DockManager1_ClosingPanel(object sender, DockPanelCanc ...
- JAVA不可不知的强软弱虚四种引用
一个变量指向new对象,就是引用,在java中有四种引用,分别是强软弱虚,常见的Object o = new Object(),就是强引用,垃圾回收的时候,强引用不会被回收. 公用类: publi ...
- E4.IO.pry/0-IO.break!/1动态打点调试
IO.pry/0 IO.inspect只能在静态地打印指定的变量,Elixir的shell还可以使用IO.pry/0与IO.break!/1实现更灵活的调试方法. 假如你想查看一下函数的某个位置到底发 ...
- 权限过大 ssh协议通过pem文件登陆
root@oneweek:~# ssh -i uat.pem root@110.5.15.6@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ...
- HTML5 学习表格应用
<table> <tr> ---tr 定义行 <td>第1个单元格的内容</td> ----td 定义列 <td>第2个单元格的内容< ...
- Java——方法
Java 方法 Systom.out.println():其中,println()是一个方法(Method),而System是系统类(Class),out是标准输出对象(Object).这句话的意思是 ...
- (转)pip和easy_install使用方式
easy_install 跟 pip 都是 Python 的套件管理程式,有了它們,在使用 Python 開發程式的時候會帶來不少方便. easy_install 和 pip 有什麼不一樣?據 pip ...