HDU 1005 number sequence
摘要:
一道数学题,纠结了好长时间,10^8 的话,用O(N)的算法一定会超时,考虑到模7,是一个循环问题,重要的是找出循环节,注意不一定是从f[1]出开始循环。。。#include<iostream>#include<cstdio>using namespace std;int f[100];int A,B;long long N;int find(int left,int right){ for(int i=1;i<left;i++) { if(f[i]==f[left]&&f[i+1]==f[right])return i; } return 0;} 阅读全文
posted @ 2011-07-16 13:25 lonelycatcher 阅读(245) 评论(0) 推荐(0) 编辑