PAT 1006.Sign In and Sign Out(25)(C++)

题目描述比较简单的水题,只需要比较到达时间和离开时间即可,建立一个结构体存储最早时间和最晚时间,方便比较。#include<iostream>using namespace std;struct da{ int hh; int mm; int ss;};int main(){ int n; string fname,lname; da earlier; earlier.hh=24; da last; last.hh=0; string name; int ho
分类: 其他 发布时间: 01-25 22:23 阅读次数: 0

PAT 1005.Spell It Right (20) (C++)

题目描述水题, 字符串的简单处理,注意数字范围#include<string>#include<iostream>using namespace std;string num[]={"zero","one","two","three","four","five","six","seven","eight","nine"};int main(){string s;cin>>s;int sum=0;for(int i=0;i<s.length();i
分类: 其他 发布时间: 01-25 22:23 阅读次数: 0

PAT 1004.Counting Leaves (30)(C++)

题目描述此题是输出每层有多少个叶子节点,可以采用DFS和BFS两种方法进行(由于长时间不练习相关题目。这么简单的题也不能很快做出来,菜 )此题是搜索基础题,需要多多练习,多多回顾DFS#include<iostream>#include<vector>#include<algorithm>using namespace std;vector<vector<int>>tree(100);int leaveNumOflLevel[1
分类: 其他 发布时间: 01-25 22:23 阅读次数: 0

PAT 1009.Product of Polynomials (25)(C++)

题目描述多项式乘法,和1002类似,1002是多项式加法,由于自己太菜一开始并未理解多项式乘法如何计算,其实本题很简单。#include<cstdio>using namespace std;double A[1005],result[2005];int main(){ int n; scanf("%d",&n); int x; double y; while(n--){ scanf("%d%lf",&x,&y); A[x]
分类: 其他 发布时间: 01-25 22:23 阅读次数: 0

POJ 2196 Specialized Four-Digit Numbers

题目描述题意:求出这样的四位数的个数,满足分别以十进制、十二进制、十六进制表示时,数字相加之和相等。题目比较简单,水题,只需要编写一个进制转换的函数#include<cstdio>using namespace std;int Calc(int base,int n){ int sum=0; while(n!=0){ sum+=n%base; n/=base; } return sum;}int main(){ for(int i=2992;i<=999
分类: 其他 发布时间: 01-25 22:22 阅读次数: 0

UVA 492 Pig-Latin

题目描述字符串处理问题,也很简单需要注意字符串的读取 用C语言getchar读取一直不对。。。。#include<iostream>#include<string>#include<set>using namespace std;bool vow(char x) { x=toupper(x); if(x=='A'||x=='E'||x=='I'||x=='O'||x=='U')return 1; return 0;} int m
分类: 其他 发布时间: 01-25 22:22 阅读次数: 0

POJ 2361 Tic Tac Toe

题目描述此题比较简单,判断当前棋盘状态是否有效无效棋盘,至少会呈现下述5种特征之一:1.O的点多于X的点2.O和X同时赢3.X的点比O的点多出2个或以上4.X赢,但X的个数与O的个数一样多5.O赢,但X比O的个数多一个#include<iostream>using namespace std;char map[4][4];bool win(char c){ for(int i=0;i<3;i++) { for(int j=0;j<3&&
分类: 其他 发布时间: 01-25 22:22 阅读次数: 0

UVA 10323 Factorial! You Must be Kidding!!!

题目描述此题题意是重新规定了整数的范围,在计算时需要注意数的范围,否则会tle#include<iostream>using namespace std;int main(){ int n; while(cin>>n){ if(n<0){ if(n%2==0) cout<<"Underflow!"<<endl; else cout<<"Overflow!"<<endl; } el
分类: 其他 发布时间: 01-25 22:21 阅读次数: 0

POJ 1597 Function Run Fun

题目描述本题是简单的一个递归函数,但是只是按照题目意思来写一定会TLE需要创建一个三维数组存储结果,采取记忆化搜索才能AC#include<iostream>#include<cstring>using namespace std;int f[21][21][21];int w(int a,int b,int c){ if(a<=0||b<=0||c<=0) return 1; else if(a>20||b>20||c>20
分类: 其他 发布时间: 01-25 22:21 阅读次数: 0

*UVA 10994 Simple Addition

题目描述每一轮求出[p, q]区间内数字的个位数的和,并计入总和;再将[p, q]区间内个位数为0的数除以10,产生新区间,进入下一轮,再求新区间内数字的个位数的和,并计入总和,而个位数为0的数除以10,产生新区间;以此类推;直到[p, q]区间内的数只有个位数此题有一定难度,需要多多思考#include<iostream>using namespace std;#define ll long longll sum;ll f(ll x){ if(x==0) return 0;
分类: 其他 发布时间: 01-25 22:21 阅读次数: 0

POJ 1581 A Contesting Decision

题目描述此题可以利用结构体进行排序,较为简单但其实不用结构体就可以#include<iostream>#include<cstring>using namespace std;int main(){ string name; int leasttime=0; int mostnum=0; int n; int x,y; int num,times; string result; cin>>n; while(n--){ cin>&
分类: 其他 发布时间: 01-25 22:21 阅读次数: 0

POJ 1008 Maya Calendar

题目描述这道题的难度并不大,只是一个日期的转换,很久之前也做过这道题1、先将输入的日期转换为距离日期开始点的天数: date = year365+month20+天数2、 根据date求出Tzolkin日历格式的年份,月份,天数 year = date/260; 数字=date%13+1; (加1是因为数字从1开始) 天名字下标=date%20;(20个天名字的下标从0到19,根据计算出的天名字下标就可以得到相应的天名字)#include <iostream&
分类: 其他 发布时间: 01-25 22:21 阅读次数: 0

POJ 1939 Diplomatic License

题目描述水题,使用结构体表示点坐标#include<cstdio>using namespace std;struct point{ long long x,y;}first,last,now;int main(){ int n; while(scanf("%d",&n)!=EOF){ printf("%d",n); scanf("%lld%lld",&first.x,&first.y); now=first; for(int i=
分类: 其他 发布时间: 01-25 22:20 阅读次数: 0

UVA 10221 Satellites

题目描述简单的数学问题,采用公式即可解决注意:角度可能超过180#define _USE_MATH_DEFINES#include<iostream>#include<cmath>using namespace std;const double r=6440;int main(){ double dis,angle; char s; while(cin>>dis>>angle>>s>>s>
分类: 其他 发布时间: 01-25 22:20 阅读次数: 0

UVA 10242 Fourth Point !!

题目描述此题较为简单,给出平行四边形三个点坐标,求第四个点坐标#include<iostream>using namespace std;typedef struct{ double x,y;}point;int main(){ point a,b,c,d,e; while(~scanf("%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y)) { ~scanf("%lf%lf%lf%lf",&c.
分类: 其他 发布时间: 01-25 22:20 阅读次数: 0

POJ 2242 The Circumference of the Circle

题目描述三点确定一个圆,利用海伦凯勒公式求出三点围成的三角形的面积,再利用正弦定理求出圆的半径s=abc/4r#include<iostream>#include<cmath>#include<cstdio>const double PI=3.141592653589793;using namespace std;int main(){ double x1,y1,x2,y2,x3,y3,a,b,c,p,s,r,len; while(cin
分类: 其他 发布时间: 01-25 22:20 阅读次数: 0

POJ 2354 Titanic

题目描述本题是求球体两点的距离,直接套用公式即可#include <iostream>#include <cstdlib>#include <cstdio>#include <cmath> using namespace std; double dist( double l1, double d1, double l2, double d2 ){ double r = 6875.0/2; double p = acos(-1.0);
分类: 其他 发布时间: 01-25 22:19 阅读次数: 0

*POJ 1214 “Accordian“ Patience

#include<cstdio>struct node{ int size; node *pre,*post; node *down; char a,b; node():pre(NULL),post(NULL),down(NULL),size(1){ }};inline void insertNode(node *&m,node *&n){ n->post=m->post; n->pre=m->pre; if(m->post
分类: 其他 发布时间: 01-25 22:19 阅读次数: 0

*UVA 11988 破损的键盘 Broken Keyboard (a.k.a. Beiju Text)

题目描述用数组模拟链表,对于每一个字符存一个next值表示下一个元素的下标对于字符[,将当前下标改为0对于字符],将当前下标改为last就是我们存的最后的下标对于其他字符,更新next即可#include <bits/stdc++.h>using namespace std;char s[100005];int last,now,nxt[100005];int main(){ while(~scanf("%s",s+1)){ int n=strlen(
分类: 其他 发布时间: 01-25 22:19 阅读次数: 0

UVA 10209 Is This Integration ?

题目描述数学问题,利用初等几何知识解决#include<cstdio>#include<cmath>using namespace std;#define pi 3.141592653589793int main(){ double a; while(scanf("%lf",&a)!=EOF){ printf("%.3lf %.3lf %.3lf\n",a*a*(1-sqrt(3.0)+pi/3),a*a*(pi/3+2*sqrt(3.0)-4),a
分类: 其他 发布时间: 01-25 22:18 阅读次数: 0