玲珑杯 J -- Just for Fun
来源:互联网 发布:python中文乱码 编辑:程序博客网 时间:2024/06/04 20:10
J -- Just for Fun
Time Limit:1s Memory Limit:64MByte
Submissions:970Solved:75
DESCRIPTION
P=NP?
INPUT
First line contains a single integer T which denotes the number of test cases. For each test case, there is two numbers which denote N and P separated by a space.(0<=N<231231,0<=P<231231)The input data is no large than 1M.
OUTPUT
For each case, output the "Y" or "N" in a single line.
SAMPLE INPUT
21 123123 0
SAMPLE OUTPUT
YY
SOLUTION
玲珑杯”ACM比赛 Round #5
本是水题,奈何坑死一群人,其实看仔细点就能发现坑点,因为题目没有说是整数,而且长度不定,有可能是0000.0000000或者0000001.000000000000,所以有人用Long long和long double存,其实都是存不下的。只能用大数模拟,所以只要判断前面的数为1或后面的数为0就AC了。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#define mem(p,k) memset(p,k,sizeof(p))#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define inf 0x5fffffff#define LL long longusing namespace std;char n[5000000],p[5000000];int main(){ int t; cin>>t; while(t--){ scanf("%s%s",&n,&p);//cout<<n<<p<<endl; int cur=0,cur2=0; for(int i=0;i<strlen(n);i++){ if(n[i]=='.'){ for(int j=i+1;j<strlen(n);j++){ if(n[j]!=48){ cur=1;break; } } break; } else if(n[i]=='1'){ cur2=1; if(i!=strlen(n)-1&&n[i+1]!='.'){ cur=1;break; } } else if(n[i]!=48){//cout<<"asd"<<endl; cur=1;break; } }//cout<<cur<<endl; if(!cur&&cur2==1){ cout<<"Y"<<endl;continue; } cur=1; for(int i=0;i<strlen(p);i++){ if(p[i]!='.'&&p[i]!=48){ cur=0;break; }//cout<<"asd"<<endl; } if(!cur)cout<<"N"<<endl; else cout<<"Y"<<endl; } return 0;}
0 0
- 玲珑杯 J -- Just for Fun
- 玲珑杯 round#5 J just for Fun
- 玲珑杯Just for Fun
- 玲珑杯Just for Fun
- 【玲珑学院OJ1065】Just for Fun(模拟)
- IPv6, just for fun!
- "SlideWindow", just for fun
- Just for fun
- just for fun
- 【摘抄】Just for fun
- Just output for fun
- Just FOR FUN
- just for fun
- just for fun
- Just For Fun:智力题【1】
- Just For Fun:智力题【2】
- just for fun in linux world
- 每天进步1%--just for fun
- 移植u-boot
- 第十一章全部上机代码
- java内存组成介绍:堆(Heap)和非堆(Non-heap)内存
- 正则表达式
- eclipse使用技巧心得分享
- 玲珑杯 J -- Just for Fun
- 哈尔滨理工 oj2293 棋盘村
- 服务降级及dubbo中的实现示例
- Android 彻底解决城区县三级联动问题(3D,2维)
- 操作系统基础知识
- 如何在Vim+Ctags+Taglist应用中添加自定义语言: systemverilog
- Linux系统下的51单片机数码管实现精准计时
- What is the exact meaning of Runtime.getRuntime().totalMemory()
- 查找一个字符串中子串出现的次数