- 博客(12)
- 资源 (1)
- 收藏
- 关注
原创 HDU 5341 Gcd and Lcm
题意:给你一个N,让你求∑i=1n∑j=1n∑k=1n∑l=1nlcm(gcd(i,j),gcd(k,l))参考论文:贾志鹏线性筛首先,考虑子问题,求这样一个东西:∑i=1n∑j=1n[(i,j)=d](中括号是一个函数:若其中的命题为真,返回1,否则返回0)转化一下,就是求1到n/d两两之间互素的数然后再乘以d就是gcd为d的数了。
2015-08-29 10:57:53 657
原创 ZOJ3824 Fiber-optic Network
Fiber-optic NetworkTime Limit: 15 Seconds Memory Limit: 262144 KBMarjar University has decided to upgrade the infrastructure of school intranet by using fiber-optic technology. There are
2015-06-15 09:41:14 457
原创 Topcoder SRM661 ColorfulLineGraphs
Problem Statement Bob is going to create a graph with N nodes. The graph will be constructed in two steps. First, Bob will take N isolated vertices, label them 1 through N and color each o
2015-06-15 00:17:26 424
原创 Aizu 1333 Beautiful Spacing
这题为某种取最值的dp提供一种解题思路,通过二分,可以使得时间复杂度从n^2降到nlogn。dp我是倒序做的,定义dp[i]表示从第i个为该行第一个单词时,最大的空格是否小于二分的答案。再定义两个指针从后往前边做边扫,再弄个前缀和判断指针之间是否有解,再来决定这个第i位的dp值的真假。#include#include#include#include#includeusing
2015-03-24 00:08:35 321
原创 SGU 477 doors
477. DoorsTime limit per test: 1.5 second(s)Memory limit: 65536 kilobytesinput: standardoutput: standardIt seems that the Museum of the Modern Technology is the only place where
2015-03-15 00:17:49 487
原创 Codeforces 489E Hiking
E. Hikingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA traveler is planning a water hike along the rive
2015-03-10 17:52:48 481
原创 LIS的另一种简单做法nlogn(带路径)
最长上升子序列(Longest Increasing Subsequence,LIS),在计算机科学上是指一个序列中最长的单调递增的子序列。第一种做法是离散化+树状数组/线段树,这种方法学了树状数组的人都能想得到。第二种是二分+dp。小了个常数,时间和空间要稍稍比前面的快那么一些。定义dp[i]=j,表示长度为i的上升自序列最小末端元素是j。下面给出代码,不详细解释。#incl
2015-01-23 19:36:19 747
原创 Codeforces 500E New Year Domino
E. New Year Dominotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCelebrating the new year, many people po
2015-01-14 14:17:36 1499
原创 Codeforces 497C Distributing Parts
C. Distributing Partstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are an assistant director in a ne
2014-12-19 10:38:30 540
原创 Topcoder SRM642 TaroCutting
Problem Statement Cat Taro has some trees in his garden. Initially, the i-th tree (0-based index) is height[i] meters tall. Each day the trees grow. For each i, the i-th tree will grow by
2014-12-17 21:01:47 375
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人