Codeforces Round #603 (Div. 2) A,B,C,D【E题待补】
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int _;
cin>>_;
while(_--){
int a[];int add=;
for(int i=;i<=;i++){
cin>>a[i];add+=a[i];
}
sort(a+,a++);
int sum1=;
int cha=a[]-a[];
if(a[]>=cha){
a[]-=cha;
int ans=;
ans=a[]+a[]/;
cout<<ans<<'\n';
}else{
cout<<min(a[]+a[],a[])<<'\n';
}
//cout<<sum<<'\n';
}
return ;
}
或者二分也行。
#include<bits/stdc++.h> using namespace std;
#define int long long
#define inf 0x3f3f3f3f3f
signed main(){
int _;int a,b,c;
cin>>_;
while(_--){
cin>>a>>b>>c;
int ans=;
int l=;
int r=;
while(l<=r){
int mid=(l+r)/;
int sum=;
sum=min(a,mid)+min(b,mid)+min(c,mid);
if(sum>=*mid){
l=mid+;
ans=max(ans,mid);
}else{
r=mid-; }
}
cout<<ans<<'\n';
}
return ;
}
直接暴力就行。但是注意要先记录出现次数然后才能更改。要不然就没了QAQ
#include<bits/stdc++.h> using namespace std;
#define int long long
string str[];
map<string,int> mp;
bool cmp(string a,string b){
return a>b;
}
signed main(){
int _;
cin>>_;
while(_--){
int n;
mp.clear();
cin>>n;
int flag=;
int s=; for(int i=;i<n;i++){
cin>>str[i];
mp[str[i]]++; }
// sort(str,str+n,cmp); for(int i=;i<n;i++){ int F=;
if(mp[str[i]]>=){
for(int j=str[i].size()-;j>=;j--){
for(int k=;k<=;k++){
string temp;
temp=str[i];
temp[j]=k+'';
if(!mp[temp]){
mp[temp]++;
s++;
mp[str[i]]--;
str[i]=temp;
F=;
}
if(F){
break;
}
}
if(F){
break;
}
}
}
}
cout<<s<<'\n';
for(int i=;i<n;i++)
cout<<str[i]<<'\n';
}
return ;
}
一共有n块钱,k个人[n/k]块钱,向下取整。
现在给你n块钱,你不知道有多少人,输出每个人可能获得多少钱
其实就是找可行方案。【好像正规做法是数论分块】
题意没理解QAQ。
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){
int _;
cin>>_;
while(_--){
int n;
cin>>n;
vector<int> ans;
map<int,int> mp;
ans.push_back();
for(int i=;i*i<=n;i++){
if(!mp[i])
ans.push_back(i);
mp[i]=;
if(!mp[n/i])
ans.push_back(n/i);
mp[n/i]=;
}
sort(ans.begin(),ans.end());
cout<<ans.size()<<'\n';
for(int i=;i<ans.size();i++){
cout<<ans[i]<<" ";
}
cout<<'\n';
}
return ;
}
思路:暴力并查集就行了。真的难受。
#include<bits/stdc++.h> using namespace std;
string str[];
int f[];
int n;
map<int,int> mp;
int getf(int v){
if(f[v]==v){
return f[v];
}else{
f[v]=getf(f[v]);
return f[v];
}
}
void merge(int u,int v){
int t1=getf(u);
int t2=getf(v);
if(t1!=t2){
f[t2]=t1;
}
}
void init(){
for(int i=;i<=n+;i++)
f[i]=i;
}
signed main(){
cin>>n;
init();
int ans=;
for(int i=;i<=n;i++){
cin>>str[i];
for(int j=;j<str[i].size();j++){
if(!mp[str[i][j]-'a']){
mp[str[i][j]-'a']=i;
}
}
}
for(int i=;i<=n;i++){
int F=;
for(int j=;j<str[i].size();j++){
if(i!=mp[str[i][j]-'a']&&F){
merge(i,mp[str[i][j]-'a']);
F=; }
}
}
for(int i=;i<=n;i++){
if(f[i]==i)
ans++;
// cout<<f[i]<<" ";
}
// cout<<'\n';
cout<<ans<<'\n';
return ;
}
【菜是原罪】
Codeforces Round #603 (Div. 2) A,B,C,D【E题待补】的更多相关文章
- Codeforces Round #604 (Div. 2) A,B,C【D题待补】
思路:直接暴力判断就OK了 #include<bits/stdc++.h> using namespace std; #define int long long signed main() ...
- Codeforces Round #603 (Div. 2) A. Sweet Problem(水.......没做出来)+C题
Codeforces Round #603 (Div. 2) A. Sweet Problem A. Sweet Problem time limit per test 1 second memory ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #298 (Div. 2) A、B、C题
题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...
- Codeforces Round #267 (Div. 2) C. George and Job(DP)补题
Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently ...
- Codeforces Round #603 (Div. 2) E. Editor 线段树
E. Editor The development of a text editor is a hard problem. You need to implement an extra module ...
- Codeforces Round #603 (Div. 2) E. Editor(线段树)
链接: https://codeforces.com/contest/1263/problem/E 题意: The development of a text editor is a hard pro ...
- Codeforces Round #603 (Div. 2) D. Secret Passwords 并查集
D. Secret Passwords One unknown hacker wants to get the admin's password of AtForces testing system, ...
- Codeforces Round #603 (Div. 2) D. Secret Passwords(并查集)
链接: https://codeforces.com/contest/1263/problem/D 题意: One unknown hacker wants to get the admin's pa ...
- Codeforces Round #603 (Div. 2) C. Everyone is a Winner! (数学)
链接: https://codeforces.com/contest/1263/problem/C 题意: On the well-known testing system MathForces, a ...
随机推荐
- (二)spring初次遇见shiro
文章目录 集成 Spring 集成中的坑 shiroFilter 的工作原理 权限配置细节 集成 Spring pom.xml 添加shiro相关的依赖 我使用的版本是 ${version.shiro ...
- awk简单使用
1.awk格式 awk [ 切割符号 ] ' [ / pattern/ ] 函数语句 ' [ 文件名 ] 2.输出对应列 $0 全部 , $1 第一列 ,$2 第二列 ...... a ...
- AVR单片机教程——点亮第一个LED
做了这么多准备,我们终于可以开始用开发板做点事了. 单片机编程与计算机编程有一些不同点.程序都要有零个或多个输入.一个或多个输出,这是两者都有的,但是计算机编程的输入输出主要靠控制台,而单片机没有. ...
- springboot整合druid、mybatis
目的: 1.springboot配置数据库连接池druid 测试druid中url监控 2.springboot整合mybatis 测试查删案例 3.springboot整合pagehelper sp ...
- C#7 进入快速迭代道路
out变量 有一定C#编程经历的园友一定没少写如下这样的代码: int speed; if (int.TryParse(speedStr, out speed)) speed*=; 注释:int.Tr ...
- 如何使用Cloud Foundry CLI把一个应用推送到MindSphere
一.登录MindSphere - Cloud Foundry 1. 安装Cloud Foundry CLI (Command Line Interface). 下载地址:https://github. ...
- for_each使用方法详解
for_each使用方法详解[转] Abstract之前在(原創) 如何使用for_each() algorithm? (C/C++) (STL)曾經討論過for_each(),不過當時功力尚淺, ...
- MIG(ddr3)工程报错解决:IO constraint DQS_BIAS\Multiple Driver Net
现象 在布线自己写的ddr3压力测试代码时,报如下错误. [Constraints 18-586]IO constraint DQS_BIAS with a setting of TRUE for c ...
- English-培训3-Please call me Beth
- AM--消息队列
kafka rocketMq零拷贝对比 https://cloud.tencent.com/developer/news/333695 还有Linux目录下的基本原理 RocketMQ Kafka C ...