上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 30 下一页

2015年3月25日

CodeForces 343A Rational Resistance :最少需要多少个1Ω电阻并串联形成目标电阻:思维

摘要: 串联1Ω电阻:R+1并联1Ω电阻:R/(R+1)这样就从目标电阻倒推回去需要多少个 1 #include 2 #include 3 #include 4 using namespace std; 5 int main() 6 { 7 long long a,b,x,tmp; 8 scanf(... 阅读全文

posted @ 2015-03-25 22:21 xiao_xin 阅读(227) 评论(0) 推荐(0) 编辑

CodeForces 132C Logo Turtle :一个字符串包含T和F,准确改变n个字符使走的距离最长:记忆化搜索

摘要: 范围比较小,直接记忆化搜索=dp[go][pos][i][cnt]表示朝向,位置,字符串行进位置,剩余操作数转移方程思考=注意cnt先可以-2 1 #include 2 #include 3 #include 4 using namespace std; 5 int dp[2][205][105][... 阅读全文

posted @ 2015-03-25 22:13 xiao_xin 阅读(150) 评论(0) 推荐(0) 编辑

CodeForces 258B Little Elephant and Elections :于1-m中找出七个数,使六个数里面的4和7个数比第七个数严格小:数位dp+dfs

摘要: 预处理sum数组,sum[i]表示1-m中有i个4或7的数有多少个,这个数位dp很好写然后就是枚举第七个数含有的4,7数目,dfs剩下的六个数= 1 #include 2 #include 3 #include 4 using namespace std; 5 #define LL long lon... 阅读全文

posted @ 2015-03-25 22:05 xiao_xin 阅读(185) 评论(0) 推荐(0) 编辑

CodeForces 197A Plate Game :轮流在矩形中放圆,先放不下者输 :博弈+思维

摘要: 如果一个放不下第二个人赢,否则第一个人放在中间,由于对称性,第二个人必败=1 #include2 #include3 int main()4 {5 int n,m,r;6 scanf("%d%d%d",&n,&m,&r);7 if (n>=r*2&&m>=r*2) printf("Fir... 阅读全文

posted @ 2015-03-25 21:49 xiao_xin 阅读(295) 评论(0) 推荐(0) 编辑

CodeForces 234F Fence :每列染成红或绿色,红绿使用有限制,使不同的颜色相邻面积最少 :dp

摘要: 比较明显的dp了=dp[i][j][flag]前i个栅栏中,红/绿颜料用了j的最小接触值具体转移见程序: 1 #include 2 #include 3 #include 4 using namespace std; 5 int dp[225][45005][2],a[225]; 6 int mai... 阅读全文

posted @ 2015-03-25 21:40 xiao_xin 阅读(221) 评论(0) 推荐(0) 编辑

CodeForces 24A Ring road :给定一个环改变最小花费使联通 :dfs

摘要: 其实就两个方向,不符合就改嘛所以从任意一个点开始,两个方向更改的最小值就是答案== 1 #include 2 #include 3 #include 4 using namespace std; 5 int n,vis[1005]; 6 struct dian{ 7 int num1,num2,... 阅读全文

posted @ 2015-03-25 20:48 xiao_xin 阅读(299) 评论(0) 推荐(0) 编辑

CodeForces 70C Lucky Tickets :找到范围最小的区间使1区间找到的a和2区间找到的b使a*b=rev(a)*rev(b)大于等于w个:技巧(尺取)+map

摘要: 转化成a/rev(a)==rev(b)/b这样就容易做了先判断大区间有没有到w个,然后开两个map进行尺取x=n1 y=1如果当前对数>=w x--,否则y++,中间有涉及到两个map的删减以及在满足情况下更新答案 1 #include 2 #include 3 #include 4 #includ... 阅读全文

posted @ 2015-03-25 20:42 xiao_xin 阅读(293) 评论(0) 推荐(0) 编辑

CodeChef RRMATRIX Strange Matrix :矩阵行列标号和列行标号,有多少个重合:数学+思维

摘要: 设i行j列=a行b列列出表达式进行化简,会发现就是个gcd 1 #include 2 #include 3 #include 4 using namespace std; 5 int gcd(int x,int y) 6 { 7 if (y==0) return x; 8 return gc... 阅读全文

posted @ 2015-03-25 20:13 xiao_xin 阅读(92) 评论(0) 推荐(0) 编辑

CodeForces 222D Olympiad : 给出所有学生两轮考试分数,某人两轮分数和>=k,求可能的最高和最低名次:思维&贪心

摘要: 最高就是第一名=最低的话贪心,一轮从大到小,另一轮从小到大,尺取最多即最多能有多少个>=k 1 #include 2 #include 3 #include 4 using namespace std; 5 int a[100005],b[100005]; 6 int main() 7 { 8 ... 阅读全文

posted @ 2015-03-25 20:08 xiao_xin 阅读(271) 评论(0) 推荐(0) 编辑

CodeForces 222B Cosmic Tables :一个矩阵对它进行k次操作,交换行、列,询问i行j列的数值:技巧

摘要: 不去实际上交换行和列=用两个数组表示当前行/列是原数组哪一行/列,这样只用交换变量 1 #include 2 #include 3 #include 4 using namespace std; 5 int a[1005][1005],idx[1005],idy[1005]; 6 int main(... 阅读全文

posted @ 2015-03-25 20:01 xiao_xin 阅读(250) 评论(0) 推荐(0) 编辑

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 30 下一页

导航