跳跳
#include<bits/stdc++.h>
using namespace std;
int gcd(int x ,int y){
return y == 0 ? x : gcd(y , x % y);
}
#define x first
#define y second
struct node{
int x , y;
}a[100020];
map<pair<int ,int >, int >m;
int n ;
int main () {
cin >> n;
for(int i = 1; i <= n ; i ++) {
cin >> a[i].x >> a[i].y;
}
int ans = 0;
for(int i = 1; i <= n ; i ++){
for(int j = 1; j <= n ; j ++){
if(i == j) continue;
int x = a[i].x - a[j].x;
int y = a[i].y - a[j].y;
if(x == 0 || y == 0){
x = x == 0 ? 0 : x / abs(x);
y = y == 0 ? 0 : y / abs(y);
}
else{
int num = (abs)(gcd(x , y));
x = x / num;
y = y / num;
}
if(!m[{x , y}]){
ans ++ ;
m[{x , y}] = 1;
}
}
}
cout << ans << endl;
}
异或和或
#include<bits/stdc++.h>
using namespace std;
int l1 , l2;
int t;
char s1[1002] , s2[1002];
int main () {
cin >> t;
while(t --){
scanf("%s%s" , &s1 , &s2);
l1 = strlen(s1);
l2 = strlen(s2);
if(l1 != l2){
cout << "NO" << endl;
continue;
}
int cnt1 = 0 , cnt2 = 0;
for(int i = 0 ; i < l1; i++){
if(s1[i] == '0')cnt1 ++;
}
for(int i = 0 ; i < l2 ; i ++){
if(s2[i] == '0')cnt2 ++;
}
if(cnt2 == 0 && cnt1 != 0)cout << "NO" << endl;
else if(cnt2 != 0 && cnt1 == 0)cout << "NO" << endl;
else cout << "YES" << endl;
}
}
标签:int,s2,s1,l2,l1,strlen,周报
From: https://www.cnblogs.com/wmjlzw1314/p/17235887.html