玲珑杯 J -- Just for Fun
2016-11-26 19:51
435 查看
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了。
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 long using 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; }
相关文章推荐
- 玲珑杯 round#5 J just for Fun
- 【摘抄】Just for fun
- 窥探 kernel,just for fun --- sys_fork,sys_vfork,sys_clone,kernel_thread
- Just for Fun-生存,社会秩序,娱乐
- using tail recursion to reverse words of line ( just for fun)
- Just For Fun Linus Torvalds 自传摘录
- 窥探 kernel,just for fun --- task_struct
- [Eclipse笔记]Just for fun – 在Eclipse下编译和运行C#的代码
- python-求在pi的方法 来自python cookbook上 just for fun
- 计算机之旅(just for fun)(未完)
- 窥探 kernel,just for fun --- sys_fork,sys_vfork,sys_clone,kernel_thread
- 尺度不变特征变换匹配算法详解Scale Invariant Feature Transform(SIFT) Just For Fun
- heap sort in python :-) just for fun
- 窥探 kernel,just for fun --- do_fork
- Just For Fun:智力题【1】
- just for fun in linux world
- 推荐阅读:Just for Fun --- Linus Torvalds 自传
- 窥探 kernel,just for fun --- copy_process
- 不眠的硅谷——Just For Fun
- 窥探 kernel,just for fun --- 内核线程