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 ...
随机推荐
- Git master合并分支时提示“Already up-to-date”
Git master合并分支时提示"Already up-to-date" 在使用Git把当前分支合并到master提示"Already up-to-date&quo ...
- Windows10下Anaconda+Tensorflow+Keras环境配置
注意!注意!!注意!!! (重要的事情说三遍) 安装前检查: 1.Tensorflow不支持Anaconda2,Tensorflow也不支持python2.7和python3.7(满满的辛酸泪!) 2 ...
- C语言的关键字和数据类型
C语言关键字 C语言数据类型
- 求亲篇:数据库操作,SqlHelper,增删改查
1.利用SqlHelper类 2.简单的数据绑定输出 string strSql = "select * from login"; DataTable dt = SqlHelper ...
- Python Django mysqlclient安装和使用
一.安装mysqlclient 网上看到很过通过命令:pip install mysqlclient 进行安装的教程,但是我却始终安装失败,遇到的错误千奇百怪,后来通过自己下载mysqlclient客 ...
- 【转载】使用Response.WriteFile输出文件以及图片
Response对象是Asp.Net应用程序中非常重要的一个内置对象,其作用为负责将服务器执行好的信息输出给客户端,可以使用Response.WriteFile方法来像客户端输出文件或者图片,输出图片 ...
- vue 鼠标移入移出事件执行多次(尤其ie)
来自:https://www.cnblogs.com/myfirstboke/p/9150809.html 侵删 <p @mouseover="over($event)" ...
- 【转载】2018年最值得期待的5大BPM厂商
部署BPM软件可以帮助企业获得竞争优势,通过分析.设计.执行.控制和调节业务流程协助企业领导者提高组织绩效. 业务流程管理(BPM)是指随着公司和组织的发展匹配业务目标和流程的行为.部署BPM软件可以 ...
- phpstom激活
phpstom官网:https://www.jetbrains.com/phpstorm/download 激活方法:激活时选择License server 填入http://idea.imsxm.c ...
- linux IPC简单学习
Posix和system v区别 所谓的IPC(进程间通信)指的是消息队列,共享内存,信号量3种机制合并起来,当然,这是个狭义的概念,只包含这三种.IPC又可以分为system v进程间通信和posi ...