随笔分类 -  codeforces

codeforces 111B Petya and Divisors
摘要:题目:DescriptionLittle Petya loves looking for numbers' divisors. One day Petya came across the following problem:You are givennqueries in the form "xiyi". For each query Petya should count how many divisors of numberxidivide none of the numbersxi - yi, xi - yi + 1, ..., xi - 1. Help him 阅读全文

posted @ 2013-12-05 22:00 uestc小田 阅读(251) 评论(0) 推荐(0)

cf #216 C - Valera and Elections
摘要:题目大意:给你一棵树,节点间的边有的有标记1,有的有标记2,问你至少选取哪几个节点使得这些节点到节点1的路径中包含了所有的标记为2的边;思路:统计每个节点下与标记为2的边相邻的节点的数目,选取的节点即为数目为1的节点编号;代码:#include#include#include#include#include#include#include#include//#define DEBUG //todousing namespace std; int nn;struct node{ int to; node *next;}*head[110000],*tail[110000];i... 阅读全文

posted @ 2013-12-01 15:37 uestc小田 阅读(234) 评论(0) 推荐(0)

cf #214 Dima and Salad
摘要:题目:分析:将b[i]*k,那么就可以得到,Σ(a[i]-b[i])=0,为了使Σa[i]最大化,可以将之转化为一个容量为0的背包问题,dp解决,dp[i][j]表示放第i件物品时容量为j时的最大值;代码:#include#include#include#include#include#include#include#define DEBUG //todousing namespace std; int nn;int n,k,a[110],b[110],rem[110],con[110],dp[110][20010],ans;void ini(){ ans=-1; cin>... 阅读全文

posted @ 2013-11-25 14:52 uestc小田 阅读(225) 评论(0) 推荐(0)

cf #213 Matrix
摘要:题目:http://codeforces.com/contest/365/problem/C题目分析:sum(x,y,z,t)=s(x,y)*s(z,t),s(x,y)=s[x]+s[x+1]+...+s[y].由于strlen(s)#include #include #include #include #include #include using namespace std;long long eq,sum[5000],slen,f[46100],ssum,ans;char s[5000];void ini();void work();int main(){ ini(); wo... 阅读全文

posted @ 2013-11-21 22:22 uestc小田 阅读(213) 评论(0) 推荐(0)

codeforces 1B Spreadsheets 解题报告
摘要:题目大意: 用26个大写字母A~Z代表1~26,例如A是1,B是2,Z是26,AA是27; 由于没有代表0的字母,因此就有例如AAAA!=0.5*BAAA;因为AAAA=26^3+26^2+26+1,而BAAA=2*26^3+26^2+26+1; 因此先求出n的位数m,然后构造出AA..A(m个A),然后在每个位置上取最大值。代码:#include #include #include #include #include using namespace std;int n;char s[20];char ans[20];int sum[20],f[20];void convert(in... 阅读全文

posted @ 2013-10-15 12:30 uestc小田 阅读(296) 评论(0) 推荐(0)

Round #204 div1 A/div 2 C :::: Jeff and Rounding
摘要:题目的大意是给你2*n个浮点数,要求你选出n对浮点数,每一对浮点数其中一个数取上限,另一个数取下限,然后求2*n个处理后浮点数的和与处理前浮点数的和的差的绝对值。即min |(a1+a2+.....+an)-([ai1+aj1]+[ai2+aj2]+.....+[ain+ajn])|;解题思路: 要注意的是 例如 2.0的上限和下限都是2.0; 首先对每一个浮点数都取其下限,这样得到的差值就是所有浮点数小数部分的和;然后则需要从2*n个数里面选出n个数取其上限,即下限加1,而如果这个数是个整数,那么不需要加1;因此统计加1个数的上限和下限即可;然后选择min abs(小数部分的和-加1的个.. 阅读全文

posted @ 2013-10-05 16:17 uestc小田 阅读(213) 评论(0) 推荐(0)

导航