Codeforces Round #188 (Div. 2)
来源:互联网 发布:知乎为什么不能提问? 编辑:程序博客网 时间:2024/06/05 17:30
很长时间没有做了,也就很长时间没有写了,rating哗哗的往下掉啊 ,已经变绿了,这次三题挂了一个,a2Y,b1Y,
A
#include <iostream>#include<cstring>#include<cstdio>using namespace std;int main(){ long long i,j,k,n,m; cin>>n>>k; m = k*2-1; if(m>n) { long long x = (n+1)/2; cout<<(k-x)*2<<endl; } else cout<<m<<endl; return 0;}
B
#include <iostream>#include<cstring>#include<cstdio>#include<algorithm>#include<stdlib.h>using namespace std;char str[1000010];int main(){ int i,j,k,n,num=0; char s1[20],s2[20]; long long s=0; cin>>str; k = strlen(str); for(i = 0 ; i < k ; i++) { if(i+5>k) break; if(str[i]=='h'&&i+5<=k) { int g=0; for(j = i ; j < i+5 ; j++) s1[g++] = str[j]; s1[g] = '\0'; if(strcmp(s1,"heavy")==0) { num++; i+=4; } } if(str[i]=='m'&&i+5<=k) { int g= 0; for(j = i ; j < i+5 ; j++) s2[g++] = str[j]; s2[g] = '\0'; if(strcmp("metal",s2)==0) { s+=num; i+=4; } } } cout<<s<<endl; return 0;}
C 之后稍改了下 就A了
#include <iostream>#include<cstring>#include<algorithm>#include<stdlib.h>using namespace std;int main(){ int i,j,k; long long a,b,m,t,g=0; cin>>a>>b>>m; if(a>=m||b>=m) { cout<<"0\n"; return 0; } if(a<b) { t = a; a = b; b = t; } if(a>0&&b<0) { g = -b/a; b = g*a+b; } long long s = a+b; long long s1 = s; long long num=1; while(s<m) { long long k = max(a,b); a = k; b = s; s = a+b; num++; if(s<=s1) { cout<<"-1\n"; return 0; } } cout<<g+num<<endl; return 0;}
- Codeforces Round #188 (Div. 2)
- Codeforces Round #188 (Div. 2)
- Codeforces Round #188 (Div. 2) B题
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- Codeforces Round #122 (Div. 2)
- Codeforces Round #121 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #125 (Div. 2)
- Codeforces Round #124 (Div. 2)
- POJ--1988--Cube Stacking
- linphone-android 编译
- poj1743(后缀数组+二分--不可重叠最长重复子串)
- 【hadoop视频】【2套】单个视频可以直接下载----方便下载
- [OGRE]1.从0开始,从2D到3D
- Codeforces Round #188 (Div. 2)
- 原生JS获取CSS属性值
- 一个计算机爱好者的不完整回忆(五十二)终极之作4
- placement new
- 【专题】数位DP(按位DP)
- Web 开发人员需知的 Web 缓存知识
- 《GOF设计模式》—观察者(OBSERVER)—Delphi源码示例:图形用户界面工具箱
- 心理学分析
- 大话数据结构之二:算法