#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题待补】的更多相关文章

  1. Codeforces Round #604 (Div. 2) A,B,C【D题待补】

    思路:直接暴力判断就OK了 #include<bits/stdc++.h> using namespace std; #define int long long signed main() ...

  2. 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 ...

  3. 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  ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Codeforces Round #603 (Div. 2) E. Editor(线段树)

    链接: https://codeforces.com/contest/1263/problem/E 题意: The development of a text editor is a hard pro ...

  8. 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, ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. iphone订阅服务在那里取消

    打开手机,找到设置,点击进去   往下拉,找到“APP Store与iTunes Store”点击进去,找到你的ID,再点击进去,输入你的密码   找到“订阅”这个选项,点击进去   进到里面后你会发 ...

  2. 处理Oracle 监听文件listener.log

       如果连接时候变得较慢 查看Oracle日志记录,可能是因为此文件太大,超过2G, 需要定期清理,(如果多用户,记得用root,可能没权限) 查看listener.log? find / -nam ...

  3. WUSTOJ 1308: 采药(Java)动态规划-01背包

    题目链接:

  4. webpack css文件编译、自动添加前缀、剥离

    1.css文件编译 webpack默认只能编译js文件,引入css需要loader支持 // css文件写入js中 npm i style-loader -D // css文件loader npm i ...

  5. SQL Server2008本地数据库调用SP发送邮件

    一.首先要对本地数据库做配置 1.通过使用数据库邮件配置向导和sp_configure存储过程配置启用数据库邮件: 注:服务器名称填写发送服务器的路径或者IP,电子邮件地址为寄件者地址 配置好数据库邮 ...

  6. ArcCatalog连接数据库报错

    ArcCatalog连接数据库报错: Failed to connect to database. Cannot connect to database because the database cl ...

  7. Redis 知识 整理

    简介 安装 启动 注意事项 使用命令 通用命令 数据结构 字符串(string) 哈希(hash) 队列(list) 集合(set) 有序集合(zset) 位图(bitcount) 事务 订阅与发布 ...

  8. Wechat alert

    企业微信号登录--注册企业号或者企业微信 添加子部门 部门添加成员 创建应用 需要接收告警的人员关注企业号 企业号已经被部门成员关注 企业号有一个可以发送消息的应用,一个授权管理员,可以使用应用给成员 ...

  9. 第四篇:python基础之杂货铺

    在这一篇中我们将对上几篇的Python零碎的知识进行补充,即字符串的格式化输出,以及深浅拷贝,接下来我们将对这两种进行一一介绍. 一.字符串格式化输出 关于字符串的格式化输出,我们需要了解为什么需要字 ...

  10. AD19新功能之跟随走线

    跟随走线 AD19新增跟随走线,比如需要按照特定的轨迹进行走线,比如要绕着一个圆进行走线,或者靠着边框走线,普通模式下的效果如下图所示,线会跟着指针跑: 在走线模式下,按住 shift + f ,然后 ...