题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005
找周期,当f(n)函数值再次出现1,1的时候就是一个循环。
#include
using namespace std;
#define maxn 1000+5
int main()
{
int a,b,n,i,f[maxn];
f[1]=1;
f[2]=1;
...
分类:
其他好文 时间:
2015-08-13 15:46:57
阅读次数:
135
题目:现在有一个用来存放整数的Hash表,Hash表的存储单位称为桶,每个桶能放3个整数,当一个桶中要放的元素超过3个时,则要将新的元素存放在溢出桶中,每个溢出桶也能放3个元素,多个溢出桶使用链表串起来。此Hash表的基桶数目为素数P,Hash表的hash函数对P取模。
#include
using namespace std;
#define P 7
#define NULL_DATA -1...
分类:
其他好文 时间:
2015-08-13 14:28:42
阅读次数:
121
链接:点击打开链接
题意:大数斐波那契
代码:#include
#include
#include
using namespace std;
#define N 10000
#define M 300
#define mod 100000000
int a[N][M];
void bignumber(){
int i,j,t;
a[1][1]=a[2][1]=a[3][1...
分类:
其他好文 时间:
2015-08-13 14:26:34
阅读次数:
105
链接:点击打开链接
题意:给出一个n,求斐波那契的前四位和后四位,并按照XXXX...XXXX的格式输出,如果不足八位直接全部输出
代码:
#include
#include
#include
#define Mod 10000
using namespace std;
long long f[100];
const int MAX=2;
typedef struct{
l...
分类:
其他好文 时间:
2015-08-13 14:23:41
阅读次数:
145
一、sort二、qsort头文件:stdlib.h1.int#include#include#includeusing namespace std;int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;//升序}int...
分类:
其他好文 时间:
2015-08-13 14:23:16
阅读次数:
128
#include"iostream"using namespace std;char ISBN[13];int main(){ cin>>ISBN; int n=0; n+=(ISBN[0]-'0')*1; n+=(ISBN[2]-'0')*2; n+=(ISBN[3]-'0')*3; ...
分类:
其他好文 时间:
2015-08-13 14:21:55
阅读次数:
149
1 #include 2 #include 3 4 using namespace std; 5 6 int main() 7 { 8 string s1, s2, s3, s4; 9 cin >> s1 >> s2 >> s3 >> s4;10 string d...
分类:
其他好文 时间:
2015-08-13 14:20:47
阅读次数:
85
典型MAP排序#include"iostream"#include"map"using namespace std;map m;int main(){ int n; cin>>n; int i; m.clear(); while(n--){ cin>>i;...
分类:
其他好文 时间:
2015-08-13 14:12:36
阅读次数:
139
d[i]表示前面i个字符划分成的最小回文串个数,那么转移i字符和之前的某个字符j构成回文串形成的新划分,所以要判断前面的字符j+1到i是不是回文串,可以用Manacher算法预处理出来。#include #include #include #includeusing namespace std;co...
分类:
其他好文 时间:
2015-08-13 14:07:59
阅读次数:
141
首先是一个贪心,一种灯泡要么全都换,要么全都不换。先排序,定义状态d[i]为前面i种灯泡的最小花费,状态转移就是从d[j],jusing namespace std;const int maxn = 1e3+3;int V[maxn], K[maxn], C[maxn], L[maxn];int d...
分类:
其他好文 时间:
2015-08-13 13:42:01
阅读次数:
104