Codeforces 512B: Fox And Jumping】的更多相关文章

B. Fox And Jumping time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negativ…
题目链接 题意说的是,有n种卡片,使用第i种卡片可以使当前自己在数轴上的位置移动 l[i],要获得使用第i种卡片的代价是 c[i],求能使自己移动到数轴上任意位置的最小代价,如果不可能则输出-1 当前所拥有的卡片由1->n,逐渐调整map里的值 #include<bits/stdc++.h> using namespace std; ; int n; int c[N],l[N]; map<int,int> dp; int gcd(int a,int b) { return b…
D. Fox And Jumping 题目连接: http://codeforces.com/contest/510/problem/D Description Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at…
D - Fox And Jumping Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 512B Description Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integer…
Fox And Jumping 题目链接:http://codeforces.com/problemset/problem/512/B dp 若所选卡片能到达区间内任意点,那么所选卡片的最大公约数为1(a*x+b*y=gcd(a,b)=1). 定义状态dp[i]:获得i需要的最小的代价. 代码如下: #include<cstdio> #include<map> #include<iostream> #define LL long long using namespace…
[题目链接]:http://codeforces.com/contest/510/problem/D [题意] 你可以买n种卡片; 每种卡片的花费对应c[i]; 当你拥有了第i种卡片之后; 你可以在任意位置x跳到x-l[i]或x+r[i]; 问你至少要花费多少钱买卡片,使得你能够跳跃到坐标轴上的任意一个整数点; [题解] 有个结论: 直接记下来吧 如果gcd(a,b)==1,那么所有的点就都能跳跃到了; 所以问题就转化为,给你n个长度,让你在这n个长度中选取若干个; 使得它们的gcd为1; 且要…
A. Fox and Box Accumulation time limit per test:1 second memory limit per test:256 megabytes Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its t…
Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card. The players take turns and Ciel takes the first…
题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易知道要用到深搜.暴力搜索--- #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; + ; char g[maxn][m…
Codeforces题号:#510D 出处: Codeforces 主要算法:map+DP 难度:4.6 思路分析: 题意:给出n张卡片,分别有l[i]和c[i].在一条无限长的纸带上,你可以选择花c[i]的钱来购买卡片i,从此以后可以向左或向右条l[i]个单位.购买其他卡片后,可以获得更多的跳跃单位.先要求至少花多少元钱才能够任意跳到纸带上任意一个位置.若不行,输出-1. 首先分析如果只有两个技能的情况.若这两个技能的跳跃长度有最大公约数(x),且满足(x > 1),则一定能跳到任意一个位置.…