首页 技术 正文
技术 2022年11月12日
0 收藏 529 点赞 4,211 浏览 2813 个字

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 求绝对值 cmathdouble 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;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,494
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295