Codeforces印象

这两天抽时间去codeforces体验了一把。

首先,果然有众多大牛存在。非常多名人一直參加每周一次的比赛。积分2000+,并參与出题。

另外。上面题目非常多。预计至少一千题。

比赛结束后,题目将转为练习题,能够持续尝试。每道题目都有标签,如greedy。 math, matrices等等,能够点击对应的标签仅仅做相关的题目。可惜我做了好几道之后才发现。

这次解决的题目

首次尝试。这次做的几个都是选的完毕人数最多的,比較简单,但还是有些东西是从中新学习到的。以后最好分类练习。

1A Theatre Square

  • 用a x a的砖块去铺满面积m x n的广场,不准破坏砖块,同意超出广场,求砖块数目
  • 分别计算长宽至少多少块就可以
  • 小技巧:(m-1)/a+1来计算长度方向的砖块数目
#include<iostream>
#include<limits>
using namespace std; int main(){
long long m,n,a;
//cout << numeric_limits<long>::max() << endl;
cin >> m >> n >> a;
cout << ((m-1)/a + 1)*((n-1)/a + 1) << endl;
return 0;
}

4A Watermelon

  • 太过简单

158A Next Round

  • 太过简单

71A Way Too Long Words

  • 给定一个单词,假设长度超过10,改成缩写形式:首字母+中间的字母个数+尾字母
  • 直接输出结果就可以

118A String Task

  • 给定一个单词,删掉全部元音字母,其余字母转换为小写并每一个字母前加.符号
  • 使用ostringstream和tolower函数
#include<iostream>
#include<sstream>
using namespace std;
int main(){
string str;
cin >> str;
ostringstream ostr;
for(auto i:str){
char t=tolower(i);
if(t == 'a' || t=='o' || t=='y'||t=='e' ||t=='u' || t=='i')
;
else
ostr<< '.' << t;
}
cout << ostr.str() << endl;
return 0;
}

158B Taxi

  • n个小组。每组不超过4人,出租车每车不能超过4人。同组人不能分开,求最少要多少辆车
  • 贪心。尽量坐满每一辆车,剩下的进行组合
#include<iostream>
#include<vector>
using namespace std; int main(){
int n;
cin >> n;
// can't initialize a vector with its element;
//vector<int> test(1,2,3,4);
vector<int> stat(4,0);
for(int i = 0;i < n;i++){
int tmp;
cin >> tmp;
stat[tmp-1] += 1;
} int num_taxi = 0;
num_taxi += stat[3];
if(stat[2]>= stat[0]){
num_taxi += stat[2];
num_taxi += (stat[1]+1)/2;
}
else{
num_taxi += stat[2];
stat[0] -= stat[2];
num_taxi += (stat[0] + stat[1]*2 -1)/4 + 1;
} cout << num_taxi << endl;
return 0;
}

50A Domino piling

  • mxn的广场用2x1的砖块铺满。至少多少块?
  • 分析m,n在为奇偶的情况下的铺法就可以

231A Team

  • 太过简单

116A Tram

  • 太多简单

131A cAPS lOCK

  • 依据特定条件更改字符串中的字母大写和小写
  • 关键是怎样遍历字符串中的字符并更改大写和小写
  • for(char &c:s) 能够方便的遍历字符串
  • cctype头文件里包括了islower,tolower,isupper,toupper等char字符处理函数
#include<iostream>
#include<cctype>
using namespace std; bool meet_rule(string s)
{
for(char &c:s.substr(1))
{
if(islower(c))
return false;
}
return true;
} int main()
{
string s;
cin >> s;
if(meet_rule(s))
{
for(char &c:s)
{
if(true )
{
if(islower(c))
c = toupper(c);
else
c = tolower(c);
}
}
}
cout << s << endl;
return 0;
}

282A Bit++

  • 太过简单

转载请注明作者:Focustc,博客地址为http://blog.csdn.net/caozhk,原文链接为点我

最新文章

  1. WPF自定义RoutedEvent事件代码段
  2. hibernate笔记--实体类映射文件&quot;*.hbm.xml&quot;详解
  3. Linux make: g++: Command not found
  4. 在Jenkins中获取GitHub对应Repository的Resource Code
  5. 关于js中的同步和异步
  6. java使用httpcomponents发送get请求
  7. Android点击Button实现功能的几种方法
  8. Springmvc整合mybatis
  9. Trie/最短的名字
  10. 在.NET项目中使用PostSharp,实现AOP面向切面编程处理
  11. 关于hibernate中hql语句 case when的写法
  12. Android4.2.2源码目录结构分析
  13. [CVPR 2017] Semantic Autoencoder for Zero-Shot Learning论文笔记
  14. node.js解析微信消息推送xml格式加密的消息
  15. python(day16)内置函数,匿名函数
  16. GDB disassemble
  17. Java博客目录
  18. 将.rpm转换为.tar.gz
  19. js动态获取select选中的option
  20. poj2635(千进制取模+同余模定理)

热门文章

  1. how can I ues Dataset to shuffle a large whole dataset?
  2. 【185天】黑马程序员27天视频学习笔记【Day14-下】
  3. [python][oldboy]字符串 format
  4. PTA 10-排序6 Sort with Swap(0, i) (25分)
  5. 测试jsonp
  6. 关于css的float
  7. LCT(Link-Cut Tree)
  8. 加速和简化构建Docker(基于Google jib)
  9. idea部署项目到远程tomcat
  10. 【NOIP2016练习】T2 花花的聚会 (树形DP,倍增)