这次还是能看的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.

Input

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.

Output

Print "Yes" if there is such a point, "No" — otherwise.

You can print every letter in any case (upper or lower).

Examples
input
3
1 1
-1 -1
2 -1
output
Yes
input
4
1 1
2 2
-1 1
-2 2
output
No
input
3
1 2
2 1
4 60
output
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 }
View Code

 

B. Position in Fraction

 

You have a fraction Codeforces Round #450 (Div. 2)  ABCD. You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.

Input

The first contains three single positive integers abc (1 ≤ a < b ≤ 105, 0 ≤ c ≤ 9).

Output

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.

Examples
input
1 2 0
output
2
input
2 3 7
output
-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 }
View Code

 

相关文章:

  • 2022-01-24
  • 2021-12-18
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2021-04-07
  • 2021-07-13
  • 2021-12-07
  • 2021-10-27
  • 2021-12-08
相关资源
相似解决方案