当前位置: 首页 > news >正文

哈尔滨企业网站建站推荐c sql网站开发

哈尔滨企业网站建站推荐,c sql网站开发,wordpress重建缩略图,襄阳seo营销C. Ball in Berland 传送门:Problem - C - Codeforces 题意: 思路:容斥原理 考虑 第 i 对情侣组合 ,男生为 a ,女生为 b ,那么考虑与之匹配的情侣 必须没有 a | b ,一共有 k 对情侣&#x…

C. Ball in Berland

传送门:Problem - C - Codeforces

题意:

 思路:容斥原理

考虑 第 i 对情侣组合  ,男生为 a ,女生为 b ,那么考虑与之匹配的情侣 必须没有 a | b

,一共有 k 对情侣, a | b 可以表示为 k - cnt[a] - cnt[b] + 1 ( cnt[a] 表示为有男生 a 的方案数 )

AC代码:

#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{int n , m , k; cin >> n >> m >> k;vector<int> cnta( n + 1 ) , cntb( m + 1 ) , a( k + 1 ) , b( k + 1 );for( int i = 1 ; i <= k ; i++ ) cin >> a[i] , cnta[a[i]]++;for( int i = 1 ; i <= k ; i++ ) cin >> b[i] , cntb[b[i]]++;int ans = 0;for( int i = 1 ; i <= k ; i++ ){ans += k - cnta[a[i]] - cntb[b[i]] + 1;}cout << ans / 2 << endl;
}
signed main()
{int tt; cin >> tt;while(tt--)solve();return 0;
}

B. Sifid and Strange Subsequences

传送门:Problem - B - Codeforces

题意:

 思路:

我们要保证 | a[i] - a[j] | 的最小值 要 >= MAX ( MAX为 a[i] 中的某一个值 )

AC代码:

#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{int n; cin >> n;vector<int> a(n + 1);for( int i = 1 ; i <= n ; i++ ) cin >> a[i];int cnt = 0; sort( a.begin() + 1 , a.end() );for( int i = 1 ; i <= n ; i++ )if( a[i] <= 0 )cnt++; // 此时的 cnt 表示 a[i] <= 0 的个数int mn = 2e18;for( int i = 1 ; i < cnt ; i++ )mn = min( mn , a[i + 1] - a[i] );for( int i = cnt + 1 ; i <= n ; i++ ){// 考虑 a[i] > 0 的情况mn = min( mn , a[i] - a[i-1] );if( mn >= a[i] )cnt++;else break;}cout << cnt << endl;
}
signed main()
{int tt; cin >> tt;while(tt--)solve();return 0;
}

传送门:Problem - A - Codeforces

A. Bestie

题意:

 思路:

首先有一个结论 gcd( n , n - 1 ) == 1

所以这个题的答案一定 <= 3 

分情况讨论即可 答案为 1 2 3时的情况

#include<bits/stdc++.h>
using namespace std;
#define int long long
int gcd( int a , int b )
{return b ? gcd( b , a % b ) : a;
}
void solve()
{int n; cin >> n;vector<int> a( n + 1 );for( int i = 1 ; i <= n ; i++ ) cin >> a[i];int g = 0;for( int i = 1 ; i <= n ; i++ )g = gcd( g , a[i] );int temp1 = 0 ;for( int i = 1 ; i <= n; i++ )temp1 = gcd( temp1 , a[i] );int temp2 = 0;for( int i = 1 ; i <= n ; i++ ){if( i == n - 1 )continue;temp2 = gcd( temp2 , a[i] );}if( g == 1 ){cout << 0 << endl;}else if( gcd( temp1 , gcd( n , a[n] ) ) == 1 ){cout << 1 << endl;}else if( gcd( temp2 , gcd( n - 1 , a[n - 1] ) ) == 1 ){cout << 2 << endl;}else cout << 3 << endl;
}
signed main()
{int tt; cin >> tt;while(tt--)solve();return 0;
}

http://www.yayakq.cn/news/970155/

相关文章:

  • 云南科技公司网站龙之向导官网
  • 微信网站页面制作电子商务平台经营者名词解释
  • 合理合规的网站链接推广方案临湘网站建设
  • 河南省住房与城乡建设部网站上海到北京物流
  • 怎么样从头开始做网站宝塔wordpress动静分离
  • 怎样做网站分流赚钱阿里巴巴1688采购平台官网
  • 网站开发需要用到哪些软件建筑面积计算规范2023下载最新版
  • 局网站建设方案室内设计软件哪个比较好
  • 阿里云建站后台建站小企业网站建设在哪能看
  • 建设网站要服务器吗快速搭建网站系统
  • 天津如何做百度的网站推广有什么做户外活动的网站吗
  • 网站设计模块网站开发员的工资
  • 宝山网站建设推广自己怎么建网站
  • thinkphp只能做网站网站建设服务费一年多少钱
  • 辽宁朝阳网站建设html5如何实现网站开发
  • 手机网站 做成app鄂尔多斯网站制作 建设推广
  • 有什么可以做翻译的网站织梦网站密码
  • 个人网站简单modernize wordpress
  • 东莞市官网网站建设价格做家常菜的网站哪个好
  • 做学校网站素材图片自己电脑做网站 带宽
  • 南京市网站免费域名注册查询入口
  • 网站首页psd下载html个人网站怎么做
  • 深圳商业网站建设哪家好微信平台网站开发
  • 淮南做网站专门做兼职的网站
  • 益阳建设企业网站视频直播间话术
  • 桂平网站建设有趣的wordpress插件
  • 阿里巴巴网站开发工具张家界做网站dcwork
  • 合肥霍山路网站建设网页制作与网站建设在线作业
  • 有什么网站可以做投票功能吗嘉祥做网站
  • 高品质网站建设公司博客和微博的区别