Codeforces Round #370 (Div. 2) C. Memory and De-Evolution【dfs+想法】
2016-09-12 16:10
417 查看
刚开始想从(x,x,x)进过一些方法得到(y,y,y),但是想了好多方法都不行。后来发现反过来想比较简单从(y,y,y)开始,按照三角形的要求得到下一个为(2*y-1,y,y),然后一直这样做下去。最后当三角形边最小的长度大于x时,就可以结束了。
#include<bits/stdc++.h> using namespace std; int x,y,ans1,ans; void dfs(int a,int b,int c) { //printf("%d %d %d %d\n",ans,a,b,c); if(c>=x) return ; c=b+a-1; if(a<c) swap(a,c); if(a<b) swap(a,b); if(b<c) swap(b,c); ans++; dfs(a,b,c); } int main() { //freopen("in.txt","r",stdin); scanf("%d%d",&x,&y); ans=0; dfs(y,y,y); printf("%d\n",ans); return 0; }
相关文章推荐
- Codeforces Round #370 (Div. 2) C. Memory and De-Evolution【逆向思维+贪心】
- 【Codeforces Round 370 (Div 2) C】【正难则反 贪心】Memory and De-Evolution
- 【Codeforces Round 370 (Div 2) E】【线段树 等比数列 区间合并】Memory and Casinos 赌场区间[l,r] l进r先出的概率
- Codeforces Round 370 (Div 2) D.Memory and Scores 【前缀和 DP】双人随机数值增减K A比B多的方案数
- 【Codeforces Round 370 (Div 2) D】【前缀和打标记】Memory and Scores 双人随机数值增减K A比B多的方案数
- 【Codeforces Round 370 (Div 2) B】【简单贪心】Memory and Trident
- Codeforces Round #370 (Div. 2) E. Memory and Casinos 线段树
- Codeforces Round #370 (Div. 2) A. Memory and Crow 水题
- 【Codeforces Round 370 (Div 2) A】【水题】Memory and Crow
- Codeforces Round #370 (Div. 2) D. Memory and Scores(DP)
- Codeforces Round #394 (Div. 2)E. Dasha and Puzzle【思维+Dfs构造】
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree dfs+set
- 想法题——Codeforces Round #190 (Div. 2)——B. Ciel and Flowers
- Codeforces Round #383 (Div. 2)C. Arpa's loud Owf and Mehrdad's evil plan(dfs&lcm)
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree dfs+set
- 【Codeforces Round 272 (Div 2)B】【暴力dfs or 组合数】Dreamoon and WiFi 问号填加减方案数使得最后恰好增量为aim
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(想法题,构造题)
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree dfs+set
- Codeforces Round #430 (Div. 2) - C. Ilya And The Tree (树形DFS)
- Codeforces Round #430 (Div. 2) C. Ilya And The Tree dfs+set