09 2013 档案
摘要:通过条件约束模拟后续全状态+暴力枚举决定变量==不超时{或者说,一边边求解一边判断正误以减少不必要的运算}统一代码风格 1 #include 2 #include 3 #include 4 using namespace std; 5 int f[4][2]={{0,-1},{0,1},{-1,0}}; 6 const int maxn=20; 7 int ans; 8 int addcha; 9 int cnt=0;10 int a[maxn][maxn];11 bool check(int n)12 {13 int aa[maxn][maxn];14 for(int i=0...
阅读全文
摘要:思维题区间内点的移动(形象)保持原有顺序+重新排序后记录初始位置(容易思路不清)+想象等效模型 1 #include 2 #include 3 #include 4 #include 5 #define maxn 10000+10 6 using namespace std; 7 struct ant 8 { 9 int ord;//记录原始位置10 int f;//-1 : L , 1 : R11 int p;12 bool operator l)55 {56 printf("Fell o...
阅读全文
摘要:枚举例子+归纳推理数轴处理曲线+固定点(将同一个点放在数轴首尾)#include#include#include#include#define eps 0.000001#define maxn 2020double a[maxn];double b[maxn];using namespace std;double abss(double n){ if (n>=0) return n;else return -n;}int main(){ int n,m; while(~scanf("%d%d",&n,&m)) { double k1=1/(n+0.0)
阅读全文
摘要:初步解题原理:代数运算+单元素极值代数运算:xi表示第i个给i-1的数量,正负表示给或得c=(a1+a2+a3....an)/na1-x1+x2=c -->x2=x1-a1+ca2-x2+x3=c -->x3=x1-a1-a2+2ca3-x3+x4=c -->x4=x1-a1-a2-a3+3c......an-xn+x1=c -->xn=x1-a1-a2-a3....-a(n-1)+(n-1)cans=max{|x1|+|x2|+|x3|+....|xn|=|x1-0|+|x1-a1+c|+|x1-a1-a2+2c|.......|x1-a1-a2-a3....-a(n
阅读全文
摘要:First bloodUVA11729 Commando Warhttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=2829题目描述:突击战你有n个部下,每个部下需要完成一向任务,第i个部下需要花B[i]分钟交代任务,然后他会立即、相互无间断的执行任务J[i]的时间。你需要按照一定顺序交代任务,一边所有任务尽早结束,不能同时给两个部下交代任务,但是他们可以同时做自己的任务。解题思路:(原先放在博客上的
阅读全文
摘要:WA的代码:#include#include#include#define LL long long#define maxn 1000+5//最多的小数位数using namespace std;double a[maxn];const double eps=1e-10;double abs(double n){ return n>0 ? n:-n;}int find(int cnt)//关键{//判断第cnt个数是否在前面出现过 for (int i=1;i<cnt;i++) { if (abs(a[i]-a[cnt])<eps) return i; }...
阅读全文
摘要:这道题用到二次筛选素数的方法,优化了时间复杂度,不然会超时;区间长度在10^6以内,可用数组标记,再大也不怎么能实现。这道题是限制多多的。题目出现的主要问题 1、TLE 2、RE主要说说RE的问题:1、用数组标记L--U的素数时,容易超下界,但是我当时写的代码没什么问题,可证明一定不会超2、这个就是个奇葩了LL s=(LL)sqrt(U+0.0);for(LL i=0;prim[i] #include#include#include#define LL long long#define maxn 46600bool flag[maxn];int prim[maxn/3+5];bool f[10
阅读全文