CodeForces 21 A+B
Jabber ID
判断邮箱地址格式是否正确。。一把心酸泪。。。跪11+,,看后台才过。。
注意给定的每个条件都要判断。。
char a[105];
int fun(char a)
{
if((a>='0'&&a<='9')||(a>='a'&&a<='z')||(a>='A'&&a<='Z')) return 1;
if(a=='_') return 1;
return 0;
}
int main()
{
while(~scanf("%s",a))
{
int len=strlen(a);
int f=0,k=0;
while(a[k]!='@'&&k<len) k++;//'@'的位置;
int kk=k;
while(a[kk]!='/'&&kk<len) kk++;//是否存在第三部分;
if(k==len||k>=16||k<1||kk-k>33||len-kk>17) f=1;//各部分长度;
if(!fun(a[k+1])||!fun(a[len-1])) f=1;
for(int i=0;i<k&&!f;i++) if(!fun(a[i])) f=1;//第一部分;
int num=0;
for(int i=k+1;i<kk&&!f;i++)//第二部分;
{
if(a[i]=='.')
{
num=0;
if(a[i+1]=='.') f=1;
continue;
}
if(!fun(a[i])) f=1;
num++;
if(num>16) f=1;
}
if(kk!=len)//如果存在第三部分;
{
for(int i=kk+1;i<len&&!f;i++) if(!fun(a[i])) f=1;
}
if(f) printf("NO\n");
else printf("YES\n");
}
return 0;
}
Intersection
A1x + B1y + C1 = 0,
A2x + B2y + C2 = 0.
,给定这6个系数判断交点个数。
只需特判有0个与无限个即可,剩下的都是1个。
#include<bits/stdc++.h>
using namespace std;
int a1,b1,c1,a2,b2,c2;
int judge()
{
if((a1==0&&b1==0&&c1!=0)||(a2==0&&b2==0&&c2!=0)) return 0;
int f=1;//只有0个(平行),1个(相交),-1(无限);
if((a2==0&&b2==0)||(a1==0&&b1==0)) return -1;//任意一点;
else if(a1!=0&&b1!=0)//有斜率;
{
if(a2!=0&&b2!=0)
{
if(a1*b2==a2*b1)//斜率相同
{
if(c1*b2==c2*b1) return -1;//过同一点说明重合;
else f=0;//斜率相同不过同一点说明平行;
}
}
}
else
{
if(a1==0&&b1!=0)//一条横线;
{
if(a2==0&&b2!=0)
{
if(c2*b1==c1*b2) f=-1;//过同一点;
else f=0;
}
}
else//一条竖线;
{
if(a2!=0&&b2==0)
{
if(c2*a1==c1*a2) f=-1;//过同一点;
else f=0;
}
}
}
return f;
}
int main()
{
while(~scanf("%d%d%d%d%d%d",&a1,&b1,&c1,&a2,&b2,&c2))
{
int f=judge();
printf("%d\n",f);
}
return 0;
}
CodeForces 21 A+B的更多相关文章
- Educational Codeforces Round 21
Educational Codeforces Round 21 A. Lucky Year 个位数直接输出\(1\) 否则,假设\(n\)十进制最高位的值为\(s\),答案就是\(s-(n\mod ...
- Educational Codeforces Round 21 D.Array Division(二分)
D. Array Division time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...
- Educational Codeforces Round 21(A.暴力,B.前缀和,C.贪心)
A. Lucky Year time limit per test:1 second memory limit per test:256 megabytes input:standard input ...
- Educational Codeforces Round 21 Problem E(Codeforces 808E) - 动态规划 - 贪心
After several latest reforms many tourists are planning to visit Berland, and Berland people underst ...
- Educational Codeforces Round 21 Problem D(Codeforces 808D)
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into t ...
- Educational Codeforces Round 21 Problem A - C
Problem A Lucky Year 题目传送门[here] 题目大意是说,只有一个数字非零的数是幸运的,给出一个数,求下一个幸运的数是多少. 这个幸运的数不是最高位的数字都是零,于是只跟最高位有 ...
- 【21.37%】【codeforces 579D】"Or" Game
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【21.21%】【codeforces round 382D】Taxes
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【21.58%】【codeforces 746D】Green and Black Tea
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- Eclipse显示空白符,及使用google代码格式化
启动Eclipse,打开Preferences对话框.菜单“window”-“Preferences”. 找到Text Editors,勾选show whitespace characters,如图: ...
- json2.js 源码解读
这一部分是对Date String Number Boolean扩展toString方法,Date的toString是返回UTC格式的字符串,而后面几个是返回原始值. function f(n) {/ ...
- hdu 2604 Queuing dp找规律 然后矩阵快速幂。坑!!
http://acm.hdu.edu.cn/showproblem.php?pid=2604 这题居然O(9 * L)的dp过不了,TLE, 更重要的是找出规律后,O(n)递推也过不了,TLE,一定 ...
- 进度条--ProgressBar和BackgroundWorker
1) 需求:就餐打卡数据处理后,插入数据库中,用进度条显示过程 2) 思路:总进度为txt文本文件的行数(数据都是按照行写入),文本文件的大小 //BackgroundWorker对象有三个主要的事件 ...
- 虚方法(virtual)
虚方法(virtual) Virtual 关键字用于修饰方法.属性.索引器或事件声明,并且允许在派生类中重写这些对象. 看一段代码: using System ; class A { public v ...
- 2. UITest相关APIs
1. XCUIApplication 这是你正在测试的应用的代理.它能让你启动应用,这样你就能执行测试了.它每次都会新起一个进程,这会多花一些时间,但是能保证测试应用时的状态是干净的,这样你需要处理的 ...
- Java&Xml教程(十一)JAXB实现XML与Java对象转换
JAXB是Java Architecture for XML Binding的缩写,用于在Java类与XML之间建立映射,能够帮助开发者很方便的將XML和Java对象进行相互转换. 本文以一个简单的例 ...
- Redis为什么这么快
Redis为什么这么快 1.完全基于内存,绝大部分请求是纯粹的内存操作,非常快速.数据存在内存中,类似于HashMap,HashMap的优势就是查找和操作的时间复杂度都是O(1): 2.数据结构简单, ...
- VBA 连接sql server的用法
cnnstr = "Provider=sqloledb;Data Source=192.211.21.8;Initial Catalog=pub;UID=账号;PWD=密码" VB ...
- 【整理】解决vue不相关组件之间的数据传递----vuex的学习笔记,解决报错this.$store.commit is not a function
解决vue不相关组件之间的数据传递----vuex的学习笔记,解决报错this.$store.commit is not a function https://www.cnblogs.com/jaso ...