Codeforces Div2 242AB
来源:互联网 发布:如何防止盗取网页源码 编辑:程序博客网 时间:2024/05/20 07:52
A、
#include<cstdio>
#include<cstring>#include<algorithm>
#include<iostream>
using namespace std;
//h是用时,sit和stand分别是两种状态的仓鼠
int main()
{
char a[205];
int sit = 0,stand = 0;
int n;
cin>> n;
getchar();
gets(a);
for(int i=0; i<n; i++){
if(a[i] == 'x')
sit++;
else stand++;
}
int h = 0;
if(sit > stand){
for(int i=0; i<n&&sit>stand; i++){
if(a[i] == 'x'){
a[i] = 'X';
sit--;
stand++;
h++;
}
}
}
else if(sit < stand){
for(int i=0; i<n&&sit<stand; i++){
if(a[i] == 'X'){
a[i] = 'x';
sit++;
stand--;
h++;
}
}
}
cout<< h<< endl;
cout<< a<< endl;
return 0;
}
B、
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
//题目就是说Tomsk要发展到1000000人口,包含加入点的最短半径。
//如果所有的点都加入人口也不够就打印-1;
//juli是各点到Tomsk的距离,renkou是人口;
int main()
{
double x, y, juli[1010];
int n, s, renkou[1010];
cin>> n>> s;
for(int i=0;i<n;i++)
{
cin>>x>>y>>renkou[i];
juli[i]=sqrt(x*x+y*y);
//printf("%.7lf\n",juli[i]);
}
for(int i=1;i<n;i++)
{
for(int j=0;j<n-i;j++)
{
if(juli[j]>juli[j+1])
{
double t=juli[j];
juli[j]=juli[j+1];
juli[j+1]=t;
int t1=renkou[j];
renkou[j]=renkou[j+1];
renkou[j+1]=t1;
}
}
}
int flag=1;
for(int i=0;i<n;i++)
{
s+=renkou[i];
if(s>=1000000)
{
flag=0;
printf("%.7lf\n",juli[i]);
break;
}
}
if(flag)printf("-1\n");
return 0;
}
······················ 就会前两题
- Codeforces Div2 242AB
- codeforces 238 div2 ab
- Codeforces Div2 243AB
- Codeforces Div2 244AB
- Codeforces Round356 div2 680AB 679ABC
- Codeforces AIM-TECH round div2 624AB 623ABC
- codeforces 789 div2 题解(AB水题,C dp,D图论)
- SRM482 DIV2 AB两题解题报告
- codeforces #78 div2 C
- codeforces 83div2
- 【codeforces #91 div2】
- codeforces 105 div2 A
- codeforces 105 div2 B
- CodeForces #120 DIV2
- Codeforces---125--div2--总结
- Codeforces-127-div2
- codeforces-div2-128
- codeforces-div2-134
- python的threading模块中threading.RLock和threading.Lock
- hdu 1548(最短路)
- oc2
- 周末总结第9周
- javax.vadition.VaditionException
- Codeforces Div2 242AB
- 从零单排c++ primer(16)
- orcad capture cis 原理图库元件封装更新design cache
- Java抽象类和接口的区别及优缺点
- 任意一条查询sql转换为查询结果集对应的数目
- 基于Ruby的元编程技术
- 【浅谈OpenCV之二】OpenCV2.4.8 模块结构解析
- 山寨币创世块的快速制作
- java 虚拟机 栈理解