#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. Keras中图像维度介绍

    报错问题: ValueError: Negative dimension size caused by subtracting 5 from 1 for 'conv2d_1/convolution' ...

  2. python 之 面向对象基础(组合和封装)

    7.4 组合 解决类与类之间代码冗余问题有两种解决方案: 1.继承:描述的是类与类之间,什么是什么的关系 2.组合:描述的是类与类之间的关系,是一种什么有什么的关系 一个类产生的对象,该对象拥有一个属 ...

  3. Python完成迪杰斯特拉算法并生成最短路径

    def Dijkstra(network,s,d):#迪杰斯特拉算法算s-d的最短路径,并返回该路径和代价 print("Start Dijstra Path……") path=[ ...

  4. DevExtreme学习笔记(一) DataGrid中js分析

    1.overviewjs采用 $(function() { $("#gridContainer").dxDataGrid({ dataSource: { store: { type ...

  5. UI5-技术篇-事务Tcode

    1.LPD_CUST 快速启动板概览 2./N/UI2/FLPD_CONF 创建目录与组(全部客户端) 3./N/UI2/FLPD_CUST 创建目录与组(当前客户端) 4./N/UI2/FLP 编辑 ...

  6. hibernate saveorupdate方法只有更新有效果,保存没有效果

    转自:https://blog.csdn.net/KAIXINLUOYE/article/details/72821014 单主键生成策略由native改成assigned后,问题解决.

  7. dao 接口定义了一个方法,报错 The method xxx is undefined for the type xxx;

    转自:https://blog.csdn.net/panshoujia/article/details/78203837 持久层(DAO层)下的一个接口 ,eclipse报了一个The method ...

  8. java网络编程--httpurlconnection

    HttpURLConnection是基于HTTP协议的,其底层通过socket通信实现.如果不设置超时(timeout),在网络异常的情况下,可能会导致程序僵死而不继续往下执行.可以通过以下两个语句来 ...

  9. shell 大型脚本工具开发实战

    拆分脚本功能,抽象函数 1.function get_all_group 返回进程组列表字符串 2.function get_all_process 返回进程名列表字符串"nginx htt ...

  10. spark 机器学习 knn 代码实现(二)

    通过knn 算法规则,计算出s2表中的员工所属的类别原始数据:某公司工资表 s1(训练数据)格式:员工ID,员工类别,工作年限,月薪(K为单位)       101       a类       8年 ...