POJ-2081 Recaman's Sequence】的更多相关文章

Recaman's Sequence Time Limit: 3000ms Memory Limit: 60000KB This problem will be judged on PKU. Original ID: 208164-bit integer IO format: %lld      Java class name: Main   The Recaman's sequence is defined by a0 = 0 ; for m > 0, am = am−1 − m if the…
                                                                                                      Recaman's Sequence Time Limit: 3000MS   Memory Limit: 60000K Total Submissions: 22363   Accepted: 9605 Description The Recaman's sequence is defined…
Recaman's Sequence Time Limit: 3000MS   Memory Limit: 60000K Total Submissions: 22566   Accepted: 9697 Description The Recaman's sequence is defined by a0 = 0 ; for m > 0, am = am−1 − m if the rsulting am is positive and not already in the sequence,…
開始还以为暴力做不出来,须要找规律,找了半天找不出来.原来直接暴力.. 代码例如以下: #include<stdio.h> int a[1000050]; int b[100000000]={0}; int main() { int i,k; a[0]=0; for(i=1;i<=500000;i++) { a[i]=a[i-1]-i; if(a[i-1]-i>0&&!b[a[i-1]-i]) a[i]=a[i-1]-i; else a[i]=a[i-1]+i; b…
[简要题意]:这个主题是很短的叙述性说明.挺easy. 不重复. [分析]:只需要加一个判断这个数是否可以是一个数组,这个数组的范围. // 3388K 0Ms #include<iostream> using namespace std; #define Max 500001 int a[Max]; bool b[10000000] = {false}; // b的数据范围是能够试出来的- void init() { a[0] = 0; b[0] = true; for(int m = 1;…
Recaman's Sequence Time Limit: 3000MS Memory Limit: 60000K Total Submissions: 22392 Accepted: 9614 Description The Recaman's sequence is defined by a0 = 0 ; for m > 0, am = am−1 − m if the rsulting am is positive and not already in the sequence, othe…
Number Sequence Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36013   Accepted: 10409 Description A single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2..…
Brackets Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 27793   Accepted: 7885   Special Judge Description Let us define a regular brackets sequence in the following way: 1. Empty sequence is a regular sequence. 2. If S is a re…
[题目链接] $O(n^2)$ 效率的 dp 递推式:${ dp }_{ i }=min\left( dp_{ j }+\overset { i }{ \underset { x=j+1 }{ max }  } \left( { a }_{ x } \right)  \right) $,其中 $\sum _{ x=j+1 }^{ i }{ { a }_{ i } } \le m$. 尝试着换一个角度看待这个问题,有一个序列 $a$,假设 $b_i$ 表示 $i$ 最左能扩展到 $b_i$ 位置,…
http://poj.org/problem?id=2478 http://acm.hdu.edu.cn/showproblem.php?pid=2824 欧拉函数模板裸题,有两种方法求出所有的欧拉函数,一是筛法,而是白书上的筛法. 首先看欧拉函数的性质: 欧拉函数是求小于n且和n互质(包括1)的正整数的个数.记为φ(n). 欧拉定理:若a与n互质,那么有a^φ(n) ≡ 1(mod n),经常用于求乘法逆元. 若p是一个质数,那么φ(p) = p-1,注意φ(1) = 1. 欧拉函数是积性函数…