这次还是能看的0 0,没出现一题掉分情况。
QAQ前两次掉分还被hack了0 0,两行清泪。
You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.
The first line contains a single positive integer n (2 ≤ n ≤ 105).
The following n lines contain coordinates of the points. The i-th of these lines contains two single integers xi and yi (|xi|, |yi| ≤ 109,xi ≠ 0). No two points coincide.
Print "Yes" if there is such a point, "No" — otherwise.
You can print every letter in any case (upper or lower).
3
1 1
-1 -1
2 -1
Yes
4
1 1
2 2
-1 1
-2 2
No
3
1 2
2 1
4 60
Yes
题意:给你n个平面上的点,能否去掉一个使得所有点在y轴一侧。给出的点不会在y轴上。
题解:水题,统计下x>0 和 x<0的数字个数就好了。
1 #include<bits/stdc++.h> 2 #define clr(x) memset(x,0,sizeof(x)) 3 #define clr_1(x) memset(x,-1,sizeof(x)) 4 #define mod 1000000007 5 #define LL long long 6 #define INF 0x3f3f3f3f 7 using namespace std; 8 int main() 9 { 10 int n,left,right,x,y; 11 left=right=0; 12 scanf("%d",&n); 13 for(int i=1;i<=n;i++) 14 { 15 scanf("%d%d",&x,&y); 16 if(x>0) 17 right++; 18 else 19 left++; 20 } 21 if(right<=1 || left<=1) 22 printf("Yes\n"); 23 else 24 printf("No\n"); 25 return 0; 26 }
B. Position in Fraction
You have a fraction . You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.
The first contains three single positive integers a, b, c (1 ≤ a < b ≤ 105, 0 ≤ c ≤ 9).
Print position of the first occurrence of digit c into the fraction. Positions are numbered from 1 after decimal point. It there is no such position, print -1.
1 2 0
2
2 3 7
-1
题意:给出一个分数$ \frac{a}{b} $ ,看c在该分数小数点后几位。
题解:$ \frac{a}{b} $化为最简$ \frac{a'}{b'} $后,我们模拟除法列竖式求答案的过程。由于列竖式的过程中余下的数总比b'小,所以最多b'个不同余数,列竖式的过程中一旦出现相同的余数则是进入了循环。所以我们最多做b'次除法就能求出c是否存在于该分数小数点后以及c的位置。
1 #include<bits/stdc++.h> 2 #define clr(x) memset(x,0,sizeof(x)) 3 #define clr_1(x) memset(x,-1,sizeof(x)) 4 #define mod 1000000007 5 #define LL long long 6 #define INF 0x3f3f3f3f 7 using namespace std; 8 int gcd(int a,int b) 9 { 10 int c; 11 while(b) 12 { 13 c=a%b; 14 a=b; 15 b=c; 16 } 17 return a; 18 } 19 int main() 20 { 21 int a,b,c,d,e,i; 22 scanf("%d%d%d",&a,&b,&c); 23 d=gcd(a,b); 24 a/=d; 25 b/=d; 26 d=a/b; 27 a-=d*b; 28 a*=10; 29 for(i=1;i<=100000;i++) 30 { 31 d=a/b; 32 a-=d*b; 33 if(d==c) 34 break; 35 a*=10; 36 } 37 if(i>100000) 38 printf("-1\n"); 39 else 40 printf("%d\n",i); 41 return 0; 42 }